comparison init.gradle @ 107:167745cd8af9

add support for private environment files in slurper format
author smith@nwoca.org
date Mon, 04 Jun 2012 23:36:30 +0100
parents 34bb1f5b9027
children 029db4d977fe
comparison
equal deleted inserted replaced
106:34bb1f5b9027 107:167745cd8af9
140 def environment = new ConfigObject() 140 def environment = new ConfigObject()
141 def environments = [] 141 def environments = []
142 142
143 file('.').eachFileMatch(~/^environment.*\.groovy$/) { envFile -> 143 file('.').eachFileMatch(~/^environment.*\.groovy$/) { envFile ->
144 def envName = envFile.name - '.groovy' 144 def envName = envFile.name - '.groovy'
145 def privateFile = file("private" + envName - "environment" + ".groovy")
145 logger.info("loading environment $envFile.name") 146 logger.info("loading environment $envFile.name")
147
146 def envCfg = slurper.parse(envFile.toURL()) 148 def envCfg = slurper.parse(envFile.toURL())
147 envCfg.merge(slurper.parse(developerPrivate)) 149 envCfg.merge(slurper.parse(developerPrivate))
150 if (privateFile.exists()) {
151 logger.info("loading private environment $privateFile")
152 envCfg.merge(slurper.parse(privateFile.toURL()))
153 }
154
148 gradle.rootProject.getProperties().find { it.key.startsWith('environment') }.each { 155 gradle.rootProject.getProperties().find { it.key.startsWith('environment') }.each {
149 it.value.split(',').each { p -> 156 it.value.split(',').each { p ->
150 def (k,v) = p.split('=') 157 def (k,v) = p.split('=')
151 logger.info("$envName: overriding " + k + "=" + v) 158 logger.info("$envName: overriding " + k + "=" + v + " in $it")
152 envCfg.put(k,v) 159 envCfg.put(k,v)
153 } 160 }
154 } 161 }
162
155 envOverrides.each { k,v -> 163 envOverrides.each { k,v ->
156 logger.info("$envName: overriding " + k + "=" + v) 164 logger.info("$envName: overriding " + k + "=" + v)
157 envCfg.put(k,v) 165 envCfg.put(k,v)
158 } 166 }
159 environment.merge(envCfg) 167 environment.merge(envCfg)