Mercurial > public > develkit
comparison init20.gradle @ 178:5a3a875a1f3e
cleanup branch handling
author | smith@nwoca.org |
---|---|
date | Sat, 13 Dec 2014 18:43:34 +0000 |
parents | 629ee17d6f39 |
children | f9087f939b0a |
comparison
equal
deleted
inserted
replaced
177:629ee17d6f39 | 178:5a3a875a1f3e |
---|---|
1 import groovy.sql.Sql | 1 import groovy.sql.Sql |
2 import groovy.transform.ToString | |
2 | 3 |
3 final GradleVersion gradleCurrent = GradleVersion.current() | 4 final GradleVersion gradleCurrent = GradleVersion.current() |
4 final GradleVersion gradleV20 = GradleVersion.version('2.0') | 5 final GradleVersion gradleV20 = GradleVersion.version('2.0') |
5 println "Gradle Version: $gradleCurrent" | 6 println "Gradle Version: $gradleCurrent" |
6 if (gradleCurrent < gradleV20) { | 7 if (gradleCurrent < gradleV20) { |
52 def shortName = springModuleTranslator[details.requested.name.replace('org.springframework.', 'spring-').replace('.', '-')] | 53 def shortName = springModuleTranslator[details.requested.name.replace('org.springframework.', 'spring-').replace('.', '-')] |
53 details.useTarget("${details.requested.group}:$shortName:${details.requested.version}") | 54 details.useTarget("${details.requested.group}:$shortName:${details.requested.version}") |
54 } | 55 } |
55 } | 56 } |
56 | 57 |
57 | 58 gradle.ext.branch = new BranchInfo(System.getenv('bamboo_planRepository_branch')) |
58 gradle.ext.branchName = System.getenv('bamboo_planRepository_branch') | 59 gradle.ext.branchName = gradle.branch.name |
59 gradle.ext.branchStream = "" | 60 gradle.ext.branchStream = gradle.branch.stream |
60 | 61 gradle.ext.branchHash = gradle.branch.hash |
61 if (!gradle.branchName) { | 62 println "${gradle.hgRepositoryUrl} ${gradle.branch}" |
62 gradle.ext.branchName = "hg branch".execute().text.trim() | 63 |
63 def rawParents = 'hg parents'.execute().text | |
64 def parent = rawParents.split('\n').find { it.startsWith("branch") }?.split(":")?.getAt(1)?.trim() | |
65 gradle.ext.branchName = parent ?: gradle.branchName | |
66 } | |
67 | |
68 if (file('.hgflow').exists()) { | |
69 def flows = new Properties() | |
70 flows.load(file('.hgflow').newReader()) | |
71 flows.stringPropertyNames().each { | |
72 if (!it.startsWith("[") && gradle.branchName.startsWith(flows.getProperty(it))) { | |
73 gradle.ext.branchStream = it | |
74 } | |
75 } | |
76 } | |
77 | |
78 gradle.branchName = gradle.branchName.replace('@', '-') | |
79 gradle.ext.branchHash = generateMD5(gradle.branchName) | |
80 loadEnvironments() | 64 loadEnvironments() |
81 | 65 |
82 gradle.environment.put('hgRepositoryUrl', gradle.hgRepositoryUrl) | 66 gradle.environment.put('hgRepositoryUrl', gradle.hgRepositoryUrl) |
83 gradle.environment.put('branchName', gradle.branchName) | 67 gradle.environment.put('branchName', gradle.branch.name) |
84 gradle.environment.put('branchStream', gradle.branchStream) | 68 gradle.environment.put('branchStream', gradle.branch.stream) |
85 gradle.environment.put('branchHash', gradle.branchHash) | 69 gradle.environment.put('branchHash', gradle.branch.hash) |
70 | |
86 | 71 |
87 | 72 |
88 rootProject.ext.indyCapable = { | 73 rootProject.ext.indyCapable = { |
89 boolean capable = true | 74 boolean capable = true |
90 try { | 75 try { |
497 environments << 'environment' | 482 environments << 'environment' |
498 gradle.ext.environments = environments | 483 gradle.ext.environments = environments |
499 | 484 |
500 } | 485 } |
501 | 486 |
502 def generateMD5(String s) { | 487 |
503 def digest = java.security.MessageDigest.getInstance("MD5") | 488 @ToString class BranchInfo { |
504 digest.update(s.bytes); | 489 def name |
505 new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0') | 490 def stream |
506 } | 491 |
492 BranchInfo(name) { | |
493 this.name = name | |
494 if (!name) { | |
495 this.name = determineName() | |
496 } | |
497 this.name = this.name.replace('@', '-') | |
498 determineStream() | |
499 } | |
500 | |
501 def getHash() { | |
502 generateMD5(name) | |
503 } | |
504 def generateMD5(String s) { | |
505 def digest = java.security.MessageDigest.getInstance("MD5") | |
506 digest.update(s.bytes); | |
507 new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0') | |
508 } | |
509 | |
510 def determineName() { | |
511 def branch = "hg branch".execute().text.trim() | |
512 def rawParents = 'hg parents'.execute().text | |
513 def parent = rawParents.split('\n').find { it.startsWith("branch") }?.split(":")?.getAt(1)?.trim() | |
514 return parent ?: branch | |
515 } | |
516 | |
517 void determineStream() { | |
518 if (new File('.hgflow').exists()) { | |
519 def flows = new Properties() | |
520 flows.load(new File('.hgflow').newReader()) | |
521 flows.stringPropertyNames().each { | |
522 if (!it.startsWith("[") && name.startsWith(flows.getProperty(it))) { | |
523 stream = it | |
524 } | |
525 } | |
526 } | |
527 } | |
528 | |
529 } | |
530 |