# HG changeset patch # User smith@nwoca.org # Date 1337104945 -3600 # Node ID f7b0f9d286b8caca15ce1e11700b381a710acedf # Parent 13a1e737ca3118b08816d89198fe6739ebaaec12 allow environment variables to be overridden on command line diff -r 13a1e737ca31 -r f7b0f9d286b8 init.gradle --- a/init.gradle Sat Mar 31 19:03:26 2012 +0100 +++ b/init.gradle Tue May 15 19:02:25 2012 +0100 @@ -111,7 +111,9 @@ 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) } + gradle.getProperty(e).flatten().each { k, v -> + println String.format(' %25s = %s',k, k.contains('password') ? "********" : v ) + } } } @@ -125,11 +127,19 @@ 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)) + gradle.rootProject.getProperties().find { it.key.startsWith('environment') }.each { + it.value.split(',').each { p -> + def (k,v) = p.split('=') + logger.info("$envName: overriding " + k + "=" + v) + envCfg.put(k,v) + } + } environment.merge(envCfg) if (envName != 'environment' ) { gradle.ext[envName] =envCfg @@ -140,4 +150,5 @@ environments << 'environment' gradle.ext.environment = environment gradle.ext.environments = environments + }