Mercurial > public > develkit
view init.gradle @ 104:13a1e737ca31
USASR-800: Fix command line env setting
author | smith@nwoca.org |
---|---|
date | Sat, 31 Mar 2012 19:03:26 +0100 |
parents | 3267840f534f |
children | f7b0f9d286b8 |
line wrap: on
line source
gradle.ext.ssdtDevelkitLocation = gradle.ext.has('ssdtDevelkitLocation') ? gradle.ssdtDevelkitLocation : 'http://hg.ssdt-ohio.org/browse/public/develkit' ant.property(file: System.getProperty('user.home') + "/.ssdt/private.properties") gradle.ext.ivyUserDir = ant.properties['ivy.default.ivy.user.dir'] ?: System.getProperty('user.home') + "/.ivy2" loadEnvironments() gradle.addListener(new ArtifactoryGradleSettings()) gradle.ext.bambooBuild = System.getenv().any { it.key.startsWith('BAMBOO')} logger.info "applying SSDT artifactory Gradle Settings (bamboo: $gradle.bambooBuild)" if (gradle.bambooBuild) { gradle.ext.ssdtGradlekitLocation = gradle.ext.has('ssdtGradlekitLocation') ? gradle.ssdtGradlekitLocation : 'http://hg.ssdt-ohio.org/ssdt/gradlekit/raw-file/tip' apply from: "${gradle.ssdtGradlekitLocation}/artifactory.gradle" } apply from: "${gradle.ssdtDevelkitLocation}/metrics.gradle" task wrapper(type: Wrapper) {} wrapper << { // patch wrapper path for 1.0-milestone-7 (http://issues.gradle.org/browse/GRADLE-1823) ant.replace(file: 'gradlew', token: '\\wrapper\\gradle-wrapper.jar',value:'/wrapper/gradle-wrapper.jar') } allprojects { task cleanLocal(description: "removes all artifacts from developer's local repository") << { def local = project.repositories.find { it.name == 'local' } if ( local ) { logger.info "removing local repo: $it" new File(System.properties['user.home'] + "/.ssdt/local-repo").deleteDir() new File(gradle.ivyUserDir + "/local").deleteDir() } } cleanLocal.onlyIf { project.repositories.any { it.name == 'local' } } } class ArtifactoryGradleSettings extends BuildAdapter implements BuildListener { def void projectsEvaluated(Gradle gradle) { def ssdtArtifactory = 'http://repos.ssdt.nwoca.org/artifactory' Project root = gradle.getRootProject() root.allprojects { def thisProject = delegate configurations.all { resolutionStrategy.cacheChangingModulesFor 120, 'minutes' resolutionStrategy.cacheDynamicVersionsFor 120, 'minutes' } repositories { if (!gradle.bambooBuild) { add(new org.apache.ivy.plugins.resolver.FileSystemResolver()) { name = 'local' addIvyPattern gradle.ivyUserDir + "/local/[module]-ivy-[revision].xml" addArtifactPattern gradle.ivyUserDir + '/local/[module]-[artifact]-[revision](-[classifier]).[ext]' descriptor = 'optional' checkmodified = true changingMatcher = 'regexp' changingPattern = '.*SNAPSHOT' force = true } } add(new org.apache.ivy.plugins.resolver.URLResolver()) { name = 'ssdt-snapshots' m2compatible = true def url = "${ssdtArtifactory}/ssdt-snapshots" addArtifactPattern("${url}/[organization]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]") addArtifactPattern("${url}/[organization]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]") addIvyPattern("${url}/[organization]/[module]/ivy-[revision].xml") checkmodified = true changingMatcher = 'regexp' changingPattern = '.*SNAPSHOT' } add(new org.apache.ivy.plugins.resolver.URLResolver()) { name = 'ssdt-releases' m2compatible = false def url = "${ssdtArtifactory}/ssdt-releases" addArtifactPattern("${url}/[organization]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]") addArtifactPattern("${url}/[organization]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]") addIvyPattern("${url}/[organization]/[module]/ivy-[revision].xml") } mavenRepo name: 'ssdt-repo', url: "${ssdtArtifactory}/ssdt-repo" } if ( thisProject.repositories.find { it.name == 'local' } ) { uploadArchives { repositories { add thisProject.repositories.local } } thisProject.tasks.add("publishLocal") { description = "Publishes this projects artifacts to developer's local repository" dependsOn = ["uploadArchives"] } } } } } task showEnvironments << { println "Defined environments: $gradle.environments" gradle.environments.each { e -> println "\n $e:" gradle.getProperty(e).flatten().each { k, v -> println String.format(' %25s = %s',k,v) } } } def loadEnvironments() { def developerPrivate = new Properties() if (file('private.properties').exists()) { developerPrivate.load(file('private.properties').newReader()) } gradle.ext.env = (hasProperty('env') ? getProperty('env') : (developerPrivate.env ?: 'dev')) println "Environment is: $gradle.env" def slurper = new ConfigSlurper(gradle.env) def environment = new ConfigObject() def environments = [] file('.').eachFileMatch(~/^environment.*\.groovy$/) { envFile -> def envName = envFile.name - '.groovy' logger.info("loading environment $envFile.name") def envCfg = slurper.parse(envFile.toURL()) envCfg.merge(slurper.parse(developerPrivate)) environment.merge(envCfg) if (envName != 'environment' ) { gradle.ext[envName] =envCfg environments << envName } } environment.merge(slurper.parse(developerPrivate)) environments << 'environment' gradle.ext.environment = environment gradle.ext.environments = environments }