Mercurial > public > develkit
changeset 105:f7b0f9d286b8
allow environment variables to be overridden on command line
author | smith@nwoca.org |
---|---|
date | Tue, 15 May 2012 19:02:25 +0100 |
parents | 13a1e737ca31 |
children | 34bb1f5b9027 |
files | init.gradle |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 + }