comparison init.gradle @ 159:0c48cfd1938b

allow projects to override branchName
author Dave Smith <smith@nwoca.org>
date Wed, 06 Nov 2013 02:13:31 +0000
parents 01c8e1e27d97
children 6af68acaf9b2
comparison
equal deleted inserted replaced
158:01c8e1e27d97 159:0c48cfd1938b
17 logger.info "Bamboo plan: ${gradle.bambooPlan}" 17 logger.info "Bamboo plan: ${gradle.bambooPlan}"
18 18
19 gradle.ext.buildTimestamp = System.currentTimeMillis().toString().padLeft(14,'0') 19 gradle.ext.buildTimestamp = System.currentTimeMillis().toString().padLeft(14,'0')
20 20
21 gradle.ext.hgRepositoryUrl = "" 21 gradle.ext.hgRepositoryUrl = ""
22 gradle.ext.branchName = "" 22 try {
23 gradle.ext.branchStream = "" 23 gradle.ext.hgRepositoryUrl = ("hg path".execute().text.split('=') ?: ['',''] )[1].trim()
24 } catch (e) { }
25
26 if (!gradle.hasProperty('branchName') ){
27 println "init: determining branch properties"
28 gradle.ext.branchName = ""
29 gradle.ext.branchStream = ""
24 30
25 gradle.ext.branchName = "hg branch".execute().text.trim() 31 gradle.ext.branchName = "hg branch".execute().text.trim()
26 def rawParents = 'hg parents'.execute().text 32 def rawParents = 'hg parents'.execute().text
27 def parent = rawParents.split('\n').find { it.startsWith("branch") }?.split(":")?.getAt(1)?.trim() 33 def parent = rawParents.split('\n').find { it.startsWith("branch") }?.split(":")?.getAt(1)?.trim()
28 gradle.ext.branchName = parent ?: gradle.branchName 34 gradle.ext.branchName = parent ?: gradle.branchName
29 35
30 try { 36
31 gradle.ext.hgRepositoryUrl = ("hg path".execute().text.split('=') ?: ['',''] )[1].trim() 37 if (file('.hgflow').exists()) {
32 } catch (e) { } 38 def flows = new Properties()
33 39 flows.load(file('.hgflow').newReader())
34 40 flows.stringPropertyNames().each {
35 if (file('.hgflow').exists()) { 41 if (!it.startsWith("[") && gradle.branchName.startsWith(flows.getProperty(it))) {
36 def flows = new Properties() 42 gradle.ext.branchStream = it
37 flows.load(file('.hgflow').newReader()) 43 }
38 flows.stringPropertyNames().each {
39 if (!it.startsWith("[") && gradle.branchName.startsWith(flows.getProperty(it))) {
40 gradle.ext.branchStream = it
41 } 44 }
42 } 45 }
43 } 46 }
44 47
45 loadEnvironments() 48 loadEnvironments()
46 49
47 gradle.environment.put('hgRepositoryUrl',gradle.hgRepositoryUrl) 50 gradle.environment.put('hgRepositoryUrl',gradle.hgRepositoryUrl)