# HG changeset patch # User smith@nwoca.org # Date 1330980993 0 # Node ID bdc17bcaf797d0e0ff7a1c18ad6f6aacb34b1250 # Parent 8d2ca00227942312f492a4b19de3eab76d7f91cf CM-130: add standard 'environment' handling for SSDt projects diff -r 8d2ca0022794 -r bdc17bcaf797 .hgignore --- a/.hgignore Mon Mar 05 14:42:03 2012 +0000 +++ b/.hgignore Mon Mar 05 20:56:33 2012 +0000 @@ -3,4 +3,4 @@ \.chg\..*$ \.rej$ \.conflict\~$ - +~$ diff -r 8d2ca0022794 -r bdc17bcaf797 init.gradle --- a/init.gradle Mon Mar 05 14:42:03 2012 +0000 +++ b/init.gradle Mon Mar 05 20:56:33 2012 +0000 @@ -4,6 +4,8 @@ ant.property(file: System.getProperty('user.home') + "/.ssdt/private.properties") gradle.ivyUserDir = ant.properties['ivy.default.ivy.user.dir'] ?: System.getProperty('user.home') + "/.ivy2" +loadEnvironments() + gradle.addListener(new ArtifactoryGradleSettings()) gradle.bambooBuild = System.getenv().any { it.key.startsWith('BAMBOO')} @@ -14,12 +16,9 @@ apply from: "${gradle.ssdtGradlekitLocation}/artifactory.gradle" } - apply from: "${gradle.ssdtDevelkitLocation}/metrics.gradle" -task wrapper(type: Wrapper) { -// gradleVersion = '1.0-milestone-7' -} +task wrapper(type: Wrapper) {} wrapper << { // patch wrapper path for 1.0-milestone-7 (http://issues.gradle.org/browse/GRADLE-1823) @@ -104,3 +103,36 @@ } } } + + +task showEnvironments << { + println "Defined environments: $environments" + environments.each { e -> + println "\n $e:" + 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()) + } + setProperty 'env', hasProperty('env') ? gradle.env : (developerPrivate.env ?: 'dev') + println "Environment is: $env" + def slurper = new ConfigSlurper(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()) + environment.merge(envCfg) + if (envName != 'environment' ) { setProperty envName,envCfg } + environments << envName + } + environment.merge(slurper.parse(developerPrivate)) +// environment['environment'] = environment + setProperty 'environment', environment + setProperty 'environments', environments +}