comparison init.gradle @ 155:6389a03379a6

CM-135: allow environment* scripts to access gradle project
author Dave Smith <smith@nwoca.org>
date Mon, 28 Oct 2013 16:00:23 +0100
parents 6666e1cd8bae
children 465c6cf6dff3
comparison
equal deleted inserted replaced
154:6666e1cd8bae 155:6389a03379a6
4 ant.property(file: System.getProperty('user.home') + "/.ssdt/private.properties") 4 ant.property(file: System.getProperty('user.home') + "/.ssdt/private.properties")
5 gradle.ext.ivyUserDir = ant.properties['ivy.default.ivy.user.dir'] ?: System.getProperty('user.home') + "/.ivy2" 5 gradle.ext.ivyUserDir = ant.properties['ivy.default.ivy.user.dir'] ?: System.getProperty('user.home') + "/.ivy2"
6 6
7 gradle.ext.ssdtProjectId = System.getenv('bamboo_project_id') ?: rootProject.name 7 gradle.ext.ssdtProjectId = System.getenv('bamboo_project_id') ?: rootProject.name
8 8
9 loadEnvironments()
10
11 gradle.addListener(new ArtifactoryGradleSettings()) 9 gradle.addListener(new ArtifactoryGradleSettings())
12 10
13 def hostname 11 def hostname
14 try { hostname = "hostname".execute().text.toLowerCase().readLines().first() } catch (e) { hostname = 'unknown'} 12 try { hostname = "hostname".execute().text.toLowerCase().readLines().first() } catch (e) { hostname = 'unknown'}
15 13
16 gradle.ext.bambooBuild = System.getenv().any { it.key.startsWith('BAMBOO')} || hostname?.startsWith('ssdt-') 14 gradle.ext.bambooBuild = System.getenv().any { it.key.startsWith('BAMBOO')} || hostname?.startsWith('ssdt-')
17 15
18 gradle.ext.bambooPlan = (System.getenv('BAMBOO_PLAN') ?: 'UNKNOWN-UNKNOWN-JOB1').split('-')[0..1].join('-') 16 gradle.ext.bambooPlan = (System.getenv('BAMBOO_PLAN') ?: 'UNKNOWN-UNKNOWN-JOB1').split('-')[0..1].join('-')
19 logger.info "Bamboo plan: ${gradle.bambooPlan}" 17 logger.info "Bamboo plan: ${gradle.bambooPlan}"
20
21 18
22 gradle.ext.buildTimestamp = System.currentTimeMillis().toString().padLeft(14,'0') 19 gradle.ext.buildTimestamp = System.currentTimeMillis().toString().padLeft(14,'0')
23 20
24 gradle.ext.hgRepositoryUrl = "" 21 gradle.ext.hgRepositoryUrl = ""
25 gradle.ext.branchName = "" 22 gradle.ext.branchName = ""
42 if (!it.startsWith("[") && gradle.branchName.startsWith(flows.getProperty(it))) { 39 if (!it.startsWith("[") && gradle.branchName.startsWith(flows.getProperty(it))) {
43 gradle.ext.branchStream = it 40 gradle.ext.branchStream = it
44 } 41 }
45 } 42 }
46 } 43 }
44
45 loadEnvironments()
47 46
48 gradle.environment.put('hgRepositoryUrl',gradle.hgRepositoryUrl) 47 gradle.environment.put('hgRepositoryUrl',gradle.hgRepositoryUrl)
49 gradle.environment.put('branchName',gradle.branchName) 48 gradle.environment.put('branchName',gradle.branchName)
50 gradle.environment.put('branchStream',gradle.branchStream) 49 gradle.environment.put('branchStream',gradle.branchStream)
51 50
359 } 358 }
360 } 359 }
361 360
362 println "Environment is: $gradle.env ($envOverrides)" 361 println "Environment is: $gradle.env ($envOverrides)"
363 def slurper = new ConfigSlurper(gradle.env) 362 def slurper = new ConfigSlurper(gradle.env)
364 def environment = new ConfigObject() 363 slurper.setBinding(['gradle': gradle ])
364
365 def environment = new ConfigObject()
365 def environments = [] 366 def environments = []
366 367
367 file('.').eachFileMatch(~/^environment.*\.groovy$/) { envFile -> 368 file('.').eachFileMatch(~/^environment.*\.groovy$/) { envFile ->
368 def envName = envFile.name - '.groovy' 369 def envName = envFile.name - '.groovy'
369 def privateFile = file("private" + envName - "environment" + ".groovy") 370 def privateFile = file("private" + envName - "environment" + ".groovy")