Mercurial > public > develkit
comparison init.gradle @ 97:bdc17bcaf797
CM-130: add standard 'environment' handling for SSDt projects
author | smith@nwoca.org |
---|---|
date | Mon, 05 Mar 2012 20:56:33 +0000 |
parents | 8d2ca0022794 |
children | 8c578d146476 |
comparison
equal
deleted
inserted
replaced
96:8d2ca0022794 | 97:bdc17bcaf797 |
---|---|
1 | 1 |
2 gradle.ssdtDevelkitLocation = gradle.hasProperty('ssdtDevelkitLocation') ? gradle.ssdtDevelkitLocation : 'http://hg.ssdt-ohio.org/browse/public/develkit' | 2 gradle.ssdtDevelkitLocation = gradle.hasProperty('ssdtDevelkitLocation') ? gradle.ssdtDevelkitLocation : 'http://hg.ssdt-ohio.org/browse/public/develkit' |
3 | 3 |
4 ant.property(file: System.getProperty('user.home') + "/.ssdt/private.properties") | 4 ant.property(file: System.getProperty('user.home') + "/.ssdt/private.properties") |
5 gradle.ivyUserDir = ant.properties['ivy.default.ivy.user.dir'] ?: System.getProperty('user.home') + "/.ivy2" | 5 gradle.ivyUserDir = ant.properties['ivy.default.ivy.user.dir'] ?: System.getProperty('user.home') + "/.ivy2" |
6 | |
7 loadEnvironments() | |
6 | 8 |
7 gradle.addListener(new ArtifactoryGradleSettings()) | 9 gradle.addListener(new ArtifactoryGradleSettings()) |
8 | 10 |
9 gradle.bambooBuild = System.getenv().any { it.key.startsWith('BAMBOO')} | 11 gradle.bambooBuild = System.getenv().any { it.key.startsWith('BAMBOO')} |
10 logger.info "applying SSDT artifactory Gradle Settings (bamboo: $gradle.bambooBuild)" | 12 logger.info "applying SSDT artifactory Gradle Settings (bamboo: $gradle.bambooBuild)" |
12 if (gradle.bambooBuild) { | 14 if (gradle.bambooBuild) { |
13 gradle.ssdtGradlekitLocation = gradle.hasProperty('ssdtGradlekitLocation') ? gradle.ssdtGradlekitLocation : 'http://hg.ssdt-ohio.org/ssdt/gradlekit/raw-file/tip' | 15 gradle.ssdtGradlekitLocation = gradle.hasProperty('ssdtGradlekitLocation') ? gradle.ssdtGradlekitLocation : 'http://hg.ssdt-ohio.org/ssdt/gradlekit/raw-file/tip' |
14 apply from: "${gradle.ssdtGradlekitLocation}/artifactory.gradle" | 16 apply from: "${gradle.ssdtGradlekitLocation}/artifactory.gradle" |
15 } | 17 } |
16 | 18 |
17 | |
18 apply from: "${gradle.ssdtDevelkitLocation}/metrics.gradle" | 19 apply from: "${gradle.ssdtDevelkitLocation}/metrics.gradle" |
19 | 20 |
20 task wrapper(type: Wrapper) { | 21 task wrapper(type: Wrapper) {} |
21 // gradleVersion = '1.0-milestone-7' | |
22 } | |
23 | 22 |
24 wrapper << { | 23 wrapper << { |
25 // patch wrapper path for 1.0-milestone-7 (http://issues.gradle.org/browse/GRADLE-1823) | 24 // patch wrapper path for 1.0-milestone-7 (http://issues.gradle.org/browse/GRADLE-1823) |
26 ant.replace(file: 'gradlew', token: '\\wrapper\\gradle-wrapper.jar',value:'/wrapper/gradle-wrapper.jar') | 25 ant.replace(file: 'gradlew', token: '\\wrapper\\gradle-wrapper.jar',value:'/wrapper/gradle-wrapper.jar') |
27 } | 26 } |
102 } | 101 } |
103 } | 102 } |
104 } | 103 } |
105 } | 104 } |
106 } | 105 } |
106 | |
107 | |
108 task showEnvironments << { | |
109 println "Defined environments: $environments" | |
110 environments.each { e -> | |
111 println "\n $e:" | |
112 getProperty(e).flatten().each { k, v -> println String.format(' %25s = %s',k,v) } | |
113 } | |
114 } | |
115 | |
116 def loadEnvironments() { | |
117 def developerPrivate = new Properties() | |
118 if (file('private.properties').exists()) { | |
119 developerPrivate.load(file('private.properties').newReader()) | |
120 } | |
121 setProperty 'env', hasProperty('env') ? gradle.env : (developerPrivate.env ?: 'dev') | |
122 println "Environment is: $env" | |
123 def slurper = new ConfigSlurper(env) | |
124 def environment = new ConfigObject() | |
125 def environments = [] | |
126 file('.').eachFileMatch(~/^environment.*\.groovy$/) { envFile -> | |
127 def envName = envFile.name - '.groovy' | |
128 logger.info("loading environment $envFile.name") | |
129 def envCfg = slurper.parse(envFile.toURL()) | |
130 environment.merge(envCfg) | |
131 if (envName != 'environment' ) { setProperty envName,envCfg } | |
132 environments << envName | |
133 } | |
134 environment.merge(slurper.parse(developerPrivate)) | |
135 // environment['environment'] = environment | |
136 setProperty 'environment', environment | |
137 setProperty 'environments', environments | |
138 } |