Mercurial > public > develkit
annotate init20-git.gradle @ 334:64a8d53c6d98
change how the version is parsed from git commands
author | Marc Davis <davis@ssdt-ohio.org> |
---|---|
date | Mon, 06 Mar 2023 15:36:07 -0500 |
parents | 7bc7c6c79d7c |
children | de8c350c511a |
rev | line source |
---|---|
311
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
1 import groovy.sql.Sql |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
2 import groovy.transform.Sortable |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
3 import groovy.transform.ToString |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
4 import groovy.transform.TupleConstructor |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
5 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
6 buildscript { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
7 repositories { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
8 maven { url 'https://docker.ssdt.io/artifactory/ssdt-repo' } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
9 maven { url 'https://docker.ssdt.io/artifactory/gradle-plugins' } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
10 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
11 dependencies { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
12 classpath 'postgresql:postgresql:9.1-901.jdbc4' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
13 classpath 'com.netflix.nebula:gradle-dependency-lock-plugin:5.0.6' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
14 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
15 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
16 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
17 final GradleVersion gradleCurrent = GradleVersion.current() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
18 final GradleVersion gradleV20 = GradleVersion.version('2.0') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
19 final GradleVersion gradleV31 = GradleVersion.version('3.1') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
20 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
21 println "Gradle Version: $gradleCurrent" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
22 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
23 if (gradleCurrent < gradleV20) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
24 throw new RuntimeException("this init script requires Gradle version 2.0 or higher") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
25 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
26 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
27 gradle.ext.ssdtDevelkitLocation = gradle.ext.has('ssdtDevelkitLocation') ? gradle.ssdtDevelkitLocation : 'http://hg.ssdt-ohio.org/browse/public/develkit' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
28 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
29 ant.property(file: System.getProperty('user.home') + "/.ssdt/private.properties") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
30 gradle.ext.ivyUserDir = ant.properties['ivy.default.ivy.user.dir'] ?: System.getProperty('user.home') + "/.ivy2" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
31 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
32 gradle.ext.ssdtProjectId = System.getenv('bamboo_project_id') ?: rootProject.name |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
33 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
34 gradle.addListener(new ArtifactoryGradleSettings()) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
35 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
36 def hostname |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
37 try { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
38 hostname = "hostname".execute().text.toLowerCase().readLines().first() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
39 } catch (e) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
40 hostname = 'unknown' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
41 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
42 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
43 gradle.ext.bambooBuild = System.getenv().any { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
44 it.key.toLowerCase().contains('bamboo') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
45 } || hostname?.startsWith('ssdt-ba') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
46 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
47 gradle.ext.bambooPlan = (System.getenv('BAMBOO_PLAN') ?: 'UNKNOWN-UNKNOWN-JOB1').split('-')[0..1].join('-') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
48 logger.info "Bamboo plan: ${gradle.bambooPlan}" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
49 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
50 gradle.ext.buildTimestamp = System.currentTimeMillis().toString().padLeft(14, '0') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
51 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
52 gradle.ext.hgRepositoryUrl = "" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
53 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
54 try { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
55 gradle.ext.hgRepositoryUrl = ("hg path".execute().text.split('=') ?: ['', ''])[1].trim() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
56 } catch (e) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
57 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
58 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
59 def springModuleTranslator = [ |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
60 'spring-transaction': 'spring-tx', |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
61 'spring-web-servlet': 'spring-webmvc', |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
62 ].withDefault { it } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
63 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
64 gradle.ext.normalizeSpring = { DependencyResolveDetails details -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
65 if (details.requested.group == 'org.springframework' && details.requested.name.startsWith('org.springframework.')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
66 def shortName = springModuleTranslator[details.requested.name.replace('org.springframework.', 'spring-').replace('.', '-')] |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
67 details.useTarget(group: 'org.springframework', name: shortName, version: details.requested.version) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
68 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
69 if (details.requested.group == 'org.springframework.security' && details.requested.name.startsWith('org.springframework.')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
70 def shortName = springModuleTranslator[details.requested.name.replace('org.springframework.', 'spring-').replace('.', '-')] |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
71 details.useTarget("${details.requested.group}:$shortName:${details.requested.version}") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
72 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
73 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
74 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
75 gradle.ext.runtimeInfo = new RuntimeInfo() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
76 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
77 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
78 if (System.env.DOCKER_HOST ) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
79 if (System.env.DOCKER_HOST.contains('tcp:')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
80 gradle.ext.dockerEngineUrl = "https:${System.env.DOCKER_HOST?.minus('tcp:')}" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
81 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
82 gradle.ext.dockerEngineUrl = System.env.DOCKER_HOST |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
83 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
84 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
85 setBranchInfo() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
86 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
87 loadEnvironments() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
88 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
89 gradle.environment.put('hgRepositoryUrl', gradle.hgRepositoryUrl) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
90 gradle.environment.put('branchName', gradle.branch.name) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
91 gradle.environment.put('branchStream', gradle.branch.stream) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
92 gradle.environment.put('branchHash', gradle.branch.hash) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
93 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
94 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
95 def cacheTimeout = 60 * 60 * 8 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
96 if (gradle.environment['dependencyTimeout']) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
97 cacheTimeout = gradle.environment['dependencyTimeout'] as Integer |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
98 println "setting changing dependency timeout to $cacheTimeout seconds" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
99 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
100 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
101 gradle.ext.cacheTimeout = cacheTimeout |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
102 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
103 rootProject.ext.indyCapable = { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
104 boolean capable = true |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
105 try { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
106 Class.forName('java.lang.invoke.MethodHandle') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
107 } catch (e) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
108 capable = false |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
109 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
110 capable && !rootProject.hasProperty('skipIndy') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
111 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
112 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
113 rootProject.ext.useIndy = { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
114 boolean indy = false |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
115 // first, check if a system property activates indy support |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
116 indy |= System.hasProperty('indy') && Boolean.valueOf(System.getProperty('indy')) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
117 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
118 // check ssdt environment for indy property. |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
119 indy |= (gradle.environment.indy) ? gradle.environment.indy.toBoolean() : false |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
120 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
121 // check if the main project has an extension property setting indy (-Pindy). |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
122 if (rootProject.hasProperty('indy')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
123 indy = (Boolean.valueOf(rootProject.indy)) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
124 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
125 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
126 // set the groovy runtime system property to ensure forked junit test will get the indy flag properly |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
127 if (indy && rootProject.indyCapable()) System.setProperty("groovy.target.indy", "true") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
128 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
129 indy && rootProject.indyCapable() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
130 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
131 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
132 println "Indy available: ${rootProject.indyCapable()} enabled: ${rootProject.useIndy()}" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
133 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
134 if (gradle.bambooBuild) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
135 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
136 file('build-number.txt').text = "build.number=${gradle.branch.buildNumber ?: -1 }\n" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
137 logger.info "applying SSDT artifactory Gradle Settings (bamboo: $gradle.bambooBuild host: $hostname)" |
326 | 138 apply from: "${gradle.ssdtDevelkitLocation}/artifactory20.gradle" |
311
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
139 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
140 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
141 if (!rootProject.hasProperty('disableMetrics')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
142 apply from: "${gradle.ssdtDevelkitLocation}/metrics.gradle" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
143 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
144 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
145 rootProject.afterEvaluate { r -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
146 if (gradle.bambooBuild && r.hasProperty('requireJavaVersion')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
147 gradle.runtimeInfo.requireJava( r.getProperty('requireJavaVersion') ) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
148 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
149 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
150 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
151 def findComponent(project, name) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
152 project.component.find { it.@name == name } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
153 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
154 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
155 if (gradleCurrent >= gradleV31) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
156 wrapper { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
157 distributionType = org.gradle.api.tasks.wrapper.Wrapper.DistributionType.ALL |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
158 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
159 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
160 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
161 allprojects { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
162 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
163 apply plugin: nebula.plugin.dependencylock.DependencyLockPlugin |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
164 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
165 dependencyLock { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
166 globalLockFile = gradle.branch.isRelease() ? 'release.lock' : 'global.lock' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
167 includeTransitives = true |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
168 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
169 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
170 configurations.all { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
171 resolutionStrategy.cacheChangingModulesFor gradle.cacheTimeout, 'seconds' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
172 resolutionStrategy.cacheDynamicVersionsFor gradle.cacheTimeout, 'seconds' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
173 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
174 configurations.all { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
175 resolutionStrategy.eachDependency { DependencyResolveDetails details -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
176 if (details.requested.group == 'org.ssdt_ohio' && !details.requested.version ) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
177 details.useVersion( "latest.${gradle.branch.defaultDependencyStatus}" ) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
178 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
179 if (details.requested.version == 'default') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
180 details.useVersion("latest.${gradle.branch.defaultDependencyStatus}" ) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
181 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
182 if (project.hasProperty("overrideCommon")) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
183 if (details.requested.group == 'org.ssdt_ohio' && details.requested.name.contains('ssdt.common.')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
184 details.useVersion(project.overrideCommon) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
185 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
186 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
187 if (project.hasProperty("overrideVui")) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
188 if (details.requested.group == 'org.ssdt_ohio' && details.requested.name.startsWith('vui.')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
189 details.useVersion(project.overrideVui) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
190 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
191 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
192 if (project.hasProperty("overrideUsasCore")) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
193 if (details.requested.group == 'org.ssdt_ohio' && details.requested.name.startsWith('usas.') && !details.requested.name.startsWith('usas.vui')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
194 details.useVersion(project.overrideUsasCore) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
195 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
196 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
197 if (project.hasProperty("overrideUspsCore")) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
198 if (details.requested.group == 'org.ssdt_ohio' && details.requested.name.startsWith('usps.') && !details.requested.name.startsWith('usps.vui')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
199 details.useVersion(project.overrideUspsCore) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
200 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
201 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
202 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
203 resolutionStrategy.force 'xml-apis:xml-apis:1.4.01' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
204 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
205 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
206 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
207 task cleanLocal(description: "removes all artifacts from developer's local repository") { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
208 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
209 doLast { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
210 def local = project.repositories.find { it.name == 'local' } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
211 if (local) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
212 logger.info "removing local repo: $it" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
213 new File(System.properties['user.home'] + "/.ssdt/local-repo").deleteDir() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
214 def localDir = new File(gradle.ivyUserDir + "/local") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
215 localDir.deleteDir() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
216 logger.info "verifying removal of local repo" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
217 if (localDir.exists()) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
218 throw new org.gradle.api.GradleException("Unable to clean ${localDir}. Files may be locked by another process.") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
219 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
220 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
221 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
222 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
223 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
224 cleanLocal.onlyIf { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
225 project.repositories.any { it.name == 'local' } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
226 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
227 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
228 project.ext.previousBuildenv = project.file('build/buildenv.txt').exists() ? project.file('build/buildenv.txt').text : 'none' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
229 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
230 tasks.addRule("Pattern: <environment>As[Test]Properties: Generates <environment>.properties as resource or Test resource") { String taskName -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
231 if ((taskName - 'Test').endsWith("AsProperties") && !taskName.startsWith('clean')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
232 // def t = taskName.contains('Test') ? processTestResources.destinationDir : processResources.destinationDir |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
233 def t = taskName.contains('Test') ? sourceSets.test.output.resourcesDir : sourceSets.main.output.resourcesDir |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
234 def e = (taskName - 'Test' - 'AsProperties').capitalize() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
235 task(taskName) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
236 ext.outputDir = t |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
237 ext.propertyFile = "${e.toLowerCase()}.properties" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
238 ext.buildenv = project.file('build/buildenv.txt') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
239 inputs.files project.file("../environment${e}.groovy"), project.file("../private${e}.groovy"), project.file('../private.properties') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
240 outputs.files new File(outputDir,propertyFile), buildenv |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
241 outputs.upToDateWhen { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
242 gradle.env == project.previousBuildenv && outputs.getFiles().every { it.exists() } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
243 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
244 doLast { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
245 t.mkdirs() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
246 outputDir.mkdirs() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
247 buildenv.text = gradle.env |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
248 def ps = gradle."environment${e}".toProperties() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
249 ps['ssdt.project'] = project.name |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
250 def pf = new File(outputDir,propertyFile) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
251 ext.outputPropertyFile = pf |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
252 ps.store(pf.newOutputStream(), "by $taskName of $this") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
253 def l = pf.readLines().sort() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
254 pf.text = l.join('\n').replaceAll("\\.PARENT","") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
255 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
256 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
257 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
258 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
259 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
260 if (gradle.hasProperty('environmentDatabase')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
261 tasks.addRule("Pattern: database{Drop|Create}...: drops or creates the environment's database") { String taskName -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
262 if (taskName.startsWith('database') && (taskName.contains('Drop') || taskName.contains('Create'))) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
263 task(taskName) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
264 doLast { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
265 def dropIt = taskName.contains("Drop") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
266 def createIt = taskName.contains("Create") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
267 def driverName = gradle.environmentDatabase.jdbc.driverClassName |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
268 def databaseUrl = gradle.environmentDatabase.jdbc.url |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
269 if (driverName != "org.postgresql.Driver") { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
270 logger.info "skipping database operation for non-postgresql driver" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
271 throw new StopActionException("driver $driverName not supported by $taskName") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
272 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
273 if (!configurations.hasProperty('jdbcdriver')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
274 throw new GradleException("databaseDrop requires a 'jdbcdriver' configuration with a postgresql (or other) driver") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
275 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
276 configurations.jdbcdriver.each { File file -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
277 GroovyObject.class.classLoader.addURL(file.toURL()) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
278 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
279 Class.forName(driverName) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
280 def url = new URI(databaseUrl.substring(5)) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
281 def jdbcBaseUrl = databaseUrl - url.path |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
282 def databaseName = url.path - "/" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
283 def adminUrl = jdbcBaseUrl + "/postgres" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
284 def sql = Sql.newInstance(adminUrl, |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
285 gradle.environmentDatabase.jdbc.username, |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
286 gradle.environmentDatabase.jdbc.password, |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
287 driverName) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
288 if (dropIt) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
289 logger.info "disconnecting sessions from $databaseName" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
290 sql.execute "REVOKE CONNECT ON DATABASE \"" + databaseName + "\" FROM public;" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
291 sql.execute "REVOKE CONNECT ON DATABASE \"" + databaseName + "\" FROM " + gradle.environmentDatabase.jdbc.username + ";" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
292 sql.execute "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '" + databaseName + "';" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
293 logger.info "dropping $databaseName (if exists) from $adminUrl" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
294 sql.execute 'DROP DATABASE IF EXISTS "' + databaseName + '";' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
295 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
296 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
297 if (createIt) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
298 logger.info "Creating database $databaseName at $adminUrl" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
299 sql.execute 'CREATE DATABASE "' + databaseName + '";' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
300 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
301 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
302 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
303 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
304 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
305 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
306 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
307 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
308 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
309 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
310 rootProject.afterEvaluate { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
311 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
312 tasks.addRule("release{Major|Minor|Patch|n.n.n|Lock}: create release branch or update release Lock file") { String taskName -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
313 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
314 if (taskName == 'releaseLock') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
315 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
316 if (!gradle.branch.isRelease()) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
317 throw new BuildCancelledException("releaseLock is only valid on release or hotfix branch.") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
318 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
319 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
320 dependencyLock.globalLockFile = 'release.lock' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
321 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
322 task('doCommitLock') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
323 doLast { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
324 println 'hg status'.execute().text |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
325 println 'hg commit release.lock -A -m "lock dynamic dependencies for release"'.execute().text |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
326 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
327 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
328 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
329 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
330 task('doForceDeleteLock') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
331 doLast { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
332 println "deleting $dependencyLock.globalLockFile" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
333 rootProject.file(dependencyLock.globalLockFile).delete() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
334 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
335 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
336 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
337 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
338 def branchTasks = ['deleteGlobalLock', 'doForceDeleteLock', 'generateGlobalLock', 'saveGlobalLock', 'doCommitLock'] |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
339 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
340 task(taskName) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
341 dependsOn branchTasks |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
342 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
343 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
344 branchTasks.tail().inject(branchTasks.head()) { a, b -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
345 tasks[b].mustRunAfter a |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
346 b |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
347 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
348 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
349 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
350 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
351 def matcher = (taskName =~ /^release(Major|Minor|Patch|\d{1,3}\.\d{1,3}\.\d{1,3})$/) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
352 if (matcher.matches()) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
353 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
354 dependencyLock.globalLockFile = 'release.lock' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
355 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
356 task('doReleaseBranch') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
357 ext.requested = matcher[0][1].toLowerCase() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
358 doLast { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
359 def releaseVersion = determineReleaseVersion(requested) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
360 def releaseStream = releaseVersion.isHotfix() ? 'hotfix' : 'release' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
361 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
362 println "-" * 60 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
363 println "Preparing to create branch\n" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
364 println "\tproject:\t${gradle.rootProject.name}" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
365 println "\tcurrent:\t${gradle.branch} ($gradle.branch.version)" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
366 println() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
367 println "\ttype :\t${releaseStream.toUpperCase()}" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
368 println "\tversion:\t${releaseVersion}" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
369 println "\ttarget :\t${releaseStream}/v${releaseVersion}" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
370 println() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
371 println("-" * 60) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
372 println "DRY RUN".center(60) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
373 println("-" * 60) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
374 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
375 println "hg flow ${releaseStream} start v${releaseVersion} --dirty --dry-run".execute().text |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
376 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
377 println "-" * 60 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
378 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
379 if (!confirmPrompt("Continue?")) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
380 throw new BuildCancelledException("release branching canceled by user request") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
381 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
382 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
383 println "hg flow ${releaseStream} start v${releaseVersion} --dirty".execute().text |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
384 println "hg update ${releaseStream}/v${releaseVersion}".execute().text |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
385 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
386 setBranchInfo() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
387 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
388 println "-" * 60 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
389 println " Be sure to execute 'releaseLock' task to update the release.lock file before proceeding." |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
390 println "-" * 60 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
391 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
392 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
393 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
394 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
395 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
396 def branchTasks = ['doReleaseBranch'] |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
397 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
398 task(taskName) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
399 dependsOn branchTasks |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
400 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
401 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
402 branchTasks.tail().inject(branchTasks.head()) { a, b -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
403 tasks[b].mustRunAfter a |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
404 b |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
405 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
406 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
407 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
408 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
409 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
410 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
411 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
412 private static String readLine(String message, String defaultValue = null) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
413 String _message = "> $message" + (defaultValue ? " [$defaultValue] " : "") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
414 if (System.console()) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
415 return System.console().readLine(_message) ?: defaultValue |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
416 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
417 println "$_message " |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
418 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
419 System.in.newReader().readLine() ?: defaultValue |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
420 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
421 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
422 private static boolean confirmPrompt(String message, boolean defaultValue = false) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
423 String defaultStr = defaultValue ? 'Y' : 'n' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
424 String consoleVal = readLine("${message} (Y|n)", defaultStr) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
425 if (consoleVal) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
426 return consoleVal.toLowerCase().startsWith('y') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
427 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
428 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
429 defaultValue |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
430 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
431 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
432 private Version determineReleaseVersion(String requested) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
433 if (requested == 'major') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
434 return gradle.branch.version.nextMajor() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
435 } else if (requested == 'minor') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
436 return gradle.branch.version.nextMinor() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
437 } else if (requested == 'patch') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
438 return gradle.branch.version.nextPatch() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
439 } else { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
440 return new Version(*requested.split(/\./)*.toInteger(), false) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
441 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
442 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
443 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
444 class ArtifactoryGradleSettings extends BuildAdapter implements BuildListener { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
445 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
446 def void projectsEvaluated(Gradle gradle) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
447 def ssdtArtifactory = 'https://docker.ssdt.io/artifactory' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
448 Project root = gradle.getRootProject() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
449 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
450 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
451 def branchVersioning = gradle.rootProject.version == 'unspecified' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
452 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
453 root.allprojects { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
454 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
455 def thisProject = delegate |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
456 thisProject.status = 'integration' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
457 if (gradle.branchStream) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
458 if (branchVersioning) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
459 thisProject.version = gradle.branch.version |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
460 thisProject.status = gradle.branch.defaultDependencyStatus |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
461 } else { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
462 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
463 thisProject.status = 'integration' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
464 def fixupVersion = thisProject.version - ".SNAPSHOT" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
465 if (gradle.branchStream == 'feature') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
466 fixupVersion = fixupVersion + ".SNAPSHOT" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
467 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
468 if (gradle.branchStream == 'develop') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
469 fixupVersion = fixupVersion + ".SNAPSHOT" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
470 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
471 if (gradle.branchStream in ['production', 'release', 'hotfix']) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
472 thisProject.status = 'release' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
473 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
474 thisProject.version = fixupVersion |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
475 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
476 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
477 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
478 repositories { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
479 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
480 if (!gradle.bambooBuild) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
481 ivy { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
482 name = 'local' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
483 artifactPattern gradle.ivyUserDir + '/local/[artifact]-[revision](-[classifier]).[ext]' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
484 ivyPattern gradle.ivyUserDir + "/local/[module]-ivy-[revision].xml" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
485 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
486 mavenLocal() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
487 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
488 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
489 if (gradle.branchStream == 'feature') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
490 ivy { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
491 name = 'ssdt-branches' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
492 url = "${ssdtArtifactory}/ssdt-branches/${gradle.branchHash}/" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
493 layout "pattern", { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
494 artifact "[organization]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
495 ivy "[organization]/[module]/ivy-[revision].xml" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
496 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
497 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
498 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
499 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
500 ivy { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
501 name = 'ssdt-releases' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
502 url = "${ssdtArtifactory}/ssdt-releases" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
503 layout "pattern", { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
504 artifact "[organization]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
505 artifact "[organization]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
506 ivy "[organization]/[module]/ivy-[revision].xml" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
507 m2compatible = true |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
508 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
509 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
510 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
511 ivy { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
512 name = 'ssdt-snapshots' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
513 url = "${ssdtArtifactory}/ssdt-snapshots" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
514 layout "pattern", { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
515 artifact "[organization]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
516 artifact "[organization]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
517 ivy "[organization]/[module]/ivy-[revision].xml" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
518 m2compatible = true |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
519 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
520 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
521 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
522 maven { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
523 name = 'ssdt-repository' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
524 url = "${ssdtArtifactory}/repository" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
525 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
526 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
527 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
528 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
529 def remoteRepos = thisProject.repositories.findAll { it.hasProperty('url') && !(it.name.toLowerCase().contains('local') || it.url.toString().contains('ssdt')) } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
530 if (remoteRepos) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
531 logger.warn "WARNING: Remote repositories configured for $thisProject:\n" + remoteRepos.collect { "\t$it.name $it.url " }.join('\n') + "\n Moved to lowest priority..." |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
532 remoteRepos.each { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
533 thisProject.repositories.remove(it) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
534 thisProject.repositories.addLast(it) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
535 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
536 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
537 logger.info "$thisProject configured repositories:\n" + thisProject.repositories.collect {"\t$it.name ${it.hasProperty('url') ? it.url : '' }" }.join('\n') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
538 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
539 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
540 if (thisProject.repositories.find { it.name == 'local' } && thisProject.getTasksByName('uploadArchives', false)) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
541 uploadArchives { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
542 repositories { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
543 add thisProject.repositories.local |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
544 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
545 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
546 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
547 thisProject.tasks.create("publishLocal") { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
548 description = "Publishes this projects artifacts to developer's local repository" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
549 dependsOn = ["uploadArchives"] |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
550 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
551 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
552 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
553 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
554 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
555 root.subprojects { p -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
556 if (root.useIndy()) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
557 def groovyIndy = p.configurations.compile.files.find { f -> f.name.startsWith('groovy-all') && f.name.contains('-indy') } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
558 if (groovyIndy) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
559 println "enabling indy compilation on $p" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
560 [compileGroovy.groovyOptions, compileTestGroovy.groovyOptions]*.with { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
561 optimizationOptions = [indy: true] |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
562 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
563 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
564 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
565 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
566 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
567 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
568 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
569 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
570 task showEnvironments { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
571 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
572 doLast { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
573 println "Defined environments: $gradle.environments" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
574 gradle.environments.each { e -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
575 println "\n $e:" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
576 gradle.getProperty(e).flatten().sort { it.key }.each { k, v -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
577 println String.format(' %25s = %s', k, k.contains('password') ? "********" : v) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
578 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
579 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
580 if (logger.isInfoEnabled()) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
581 println "System properties:" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
582 System.properties.each { println " $it" } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
583 println "env variables:" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
584 System.getenv().each { println " $it" } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
585 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
586 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
587 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
588 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
589 def loadEnvironments() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
590 def developerPrivate = new Properties() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
591 if (file('private.properties').exists()) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
592 developerPrivate.load(file('private.properties').newReader()) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
593 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
594 def envOverrides = [:] |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
595 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
596 if (!hasProperty('env')) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
597 gradle.ext.env = developerPrivate.env ?: 'dev' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
598 } else { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
599 def values = getProperty('env').split(',') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
600 gradle.ext.env = values.first() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
601 values.tail().each { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
602 def (k, v) = it.split('=') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
603 envOverrides.put(k, v) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
604 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
605 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
606 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
607 println "Environment is: $gradle.env ($envOverrides)" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
608 def slurper = new ConfigSlurper(gradle.env) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
609 slurper.setBinding(['gradle': gradle]) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
610 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
611 def environment = slurper.parse( |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
612 '''deploy.mode="production" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
613 environments { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
614 test { deploy.mode="test" } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
615 dev { deploy.mode="development"} |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
616 }''') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
617 if (developerPrivate['deploy.mode']) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
618 environment.put('deploy.mode', developerPrivate['deploy.mode']) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
619 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
620 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
621 environment.put('branchInfo',gradle.branch) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
622 environment.put('branchVersion',gradle.branch.version.toString()) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
623 def environments = [] |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
624 gradle.ext.environment = environment |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
625 file('.').listFiles().findAll { it.name ==~ /^environment.*\.groovy$/ }.sort { it.name }.each { envFile -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
626 def envName = envFile.name - '.groovy' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
627 def privateFile = file("private" + envName - "environment" + ".groovy") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
628 logger.info("loading environment $envFile.name") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
629 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
630 def envCfg = slurper.parse(envFile.toURL()) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
631 envCfg.merge(slurper.parse(developerPrivate)) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
632 envCfg.put('ssdt.projectid', gradle.ssdtProjectId) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
633 envCfg.put('ssdt.environment', gradle.env) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
634 if (privateFile.exists()) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
635 logger.info("loading private environment $privateFile") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
636 envCfg.merge(slurper.parse(privateFile.toURL())) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
637 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
638 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
639 gradle.rootProject.getProperties().find { it.key.startsWith('environment') }.each { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
640 it.value.split(',').each { p -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
641 def (k, v) = p.split('=') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
642 logger.info("$envName: overriding " + k + "=" + v + " in $it") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
643 envCfg.put(k, v) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
644 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
645 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
646 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
647 envOverrides.each { k, v -> |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
648 logger.info("$envName: overriding " + k + "=" + v) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
649 envCfg.put(k, v) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
650 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
651 environment.merge(envCfg) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
652 if (envName != 'environment') { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
653 gradle.ext[envName] = envCfg |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
654 environments << envName |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
655 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
656 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
657 environment.merge(slurper.parse(developerPrivate)) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
658 def deployMode = environment.deploy.mode ?: 'development' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
659 environments.each { gradle.ext[it].put('ssdt.deployment.mode', deployMode) } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
660 environments << 'environment' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
661 gradle.ext.environments = environments |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
662 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
663 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
664 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
665 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
666 @ToString(includeNames=true) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
667 class RuntimeInfo { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
668 // OS memory in megabytes, zero if unknown |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
669 int systemMemory = 0 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
670 int systemFreeMemory = 0 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
671 String javaVersion = System.getProperty('java.version') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
672 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
673 RuntimeInfo() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
674 try { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
675 new File('/proc/meminfo').readLines().findAll { it.startsWith 'Mem' }.collect { it.split(/\s+/) }.each { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
676 int value = (it[1] as Long) / 1024 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
677 if (it[0].startsWith('MemTotal')) { systemMemory = value } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
678 if (it[0].startsWith('MemFree')) { systemFreeMemory = value } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
679 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
680 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
681 } catch (e) { } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
682 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
683 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
684 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
685 void requireMemory(int megabytes) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
686 if (systemFreeMemory > 0 && systemFreeMemory < megabytes) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
687 println "WARNING: potentially insufficent OS memory for this build" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
688 // throw new GradleException("insufficent free OS memory for this build (available: ${systemFreeMemory}m, required: ${megabytes}m)") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
689 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
690 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
691 /** |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
692 * Returns maximum memory available upto the value specified. |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
693 */ |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
694 int maxMemory(int megabytes) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
695 if (systemFreeMemory) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
696 [systemFreeMemory,megabytes].min() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
697 } else { megabytes } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
698 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
699 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
700 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
701 void requireJava(String version) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
702 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
703 if ( version && !javaVersion.startsWith(version)) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
704 throw new GradleException("Requires java version $version but running under $javaVersion") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
705 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
706 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
707 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
708 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
709 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
710 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
711 @TupleConstructor |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
712 @Sortable |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
713 class Version { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
714 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
715 Integer major = 0 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
716 Integer minor = 0 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
717 Integer patch = 0 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
718 Boolean snapshot = true |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
719 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
720 Version nextMajor() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
721 new Version(major + 1, 0, 0, false) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
722 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
723 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
724 Version nextMinor() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
725 if (snapshot) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
726 new Version(major, minor , 0,false) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
727 } else { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
728 new Version(major, minor + 1, 0,false) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
729 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
730 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
731 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
732 Version nextPatch() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
733 new Version(major, minor, patch + 1,false) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
734 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
735 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
736 Version nextSnapshot() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
737 new Version(major, minor + 1, 0) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
738 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
739 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
740 boolean isHotfix() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
741 !snapshot && patch > 0 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
742 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
743 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
744 String toString() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
745 "${major}.${minor}.${patch}${snapshot ? '.SNAPSHOT' : ''}" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
746 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
747 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
748 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
749 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
750 void setBranchInfo() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
751 gradle.ext.branch = new BranchInfo(System.getenv('bamboo_planRepository_branch')) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
752 gradle.ext.branchName = gradle.branch.name |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
753 gradle.ext.branchStream = gradle.branch.stream |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
754 gradle.ext.branchHash = gradle.branch.hash |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
755 println "${gradle.hgRepositoryUrl} ${gradle.branch} ${gradle.branch.version}" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
756 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
757 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
758 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
759 @ToString(includes=['name','shortName','buildVersion','imageId','deployName'],includeNames= true) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
760 class BranchInfo { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
761 def name |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
762 def stream = "none" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
763 def buildNumber = "" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
764 def changeset = "" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
765 def version |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
766 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
767 BranchInfo(name) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
768 this.name = name |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
769 if (!name) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
770 this.name = determineName() ?: '' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
771 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
772 this.name = this.name.replace('@', '-') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
773 determineStream() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
774 buildNumber = System.getenv('bamboo_buildNumber') ?: "" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
775 changeset = System.getenv('bamboo_planRepository_revision') ?: "" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
776 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
777 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
778 String getDefaultDependencyStatus() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
779 return isRelease() ? 'release' : 'integration' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
780 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
781 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
782 private boolean isRelease() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
783 return stream in ['release', 'hotfix'] |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
784 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
785 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
786 def getShortName() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
787 def result = name.contains('/') ? name.split('/')[1] : name |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
788 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
789 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
790 String getBuildVersion() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
791 def v = isRelease() ? shortName - "v": "" |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
792 return v |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
793 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
794 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
795 def Version getVersion() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
796 if (!version) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
797 if (isRelease()) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
798 version = new Version(*getBuildVersion().split('\\.')*.toInteger(), false) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
799 } else { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
800 version = findSnapshotVersion() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
801 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
802 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
803 return version |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
804 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
805 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
806 def getImageId() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
807 (buildVersion ?: shortName.take(25)) + (buildNumber ? "-${buildNumber}" : "-0") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
808 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
809 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
810 def getDeployName() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
811 (buildVersion ?: shortName.take(25)).toLowerCase().collectReplacements { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
812 ('a'..'z').contains(it) || ('0'..'9').contains(it) || it == "-" ? null : '-' |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
813 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
814 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
815 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
816 def getHash() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
817 generateMD5(name) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
818 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
819 def generateMD5(String s) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
820 def digest = java.security.MessageDigest.getInstance("MD5") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
821 digest.update(s.bytes); |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
822 new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
823 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
824 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
825 private findSnapshotVersion() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
826 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
827 try { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
828 def repositoryUrl = System.getenv('bamboo_planRepository_repositoryUrl') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
829 if (repositoryUrl) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
830 println "git pull $repositoryUrl".execute().text |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
831 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
832 def versions = "git tag".execute().text.split("\n") |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
833 .findAll { it != null || it != "" } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
834 .collect { it.replace("v", "") } |
331
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
835 .collect { |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
836 Version v = null |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
837 try { |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
838 v = new Version(*it.split('\\.')*.toInteger()) |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
839 return v |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
840 } catch (ignored) { |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
841 //non semver tag found, ignoring |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
842 } |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
843 } |
311
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
844 .sort { v1, v2 -> v2 <=> v1 } |
331
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
845 |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
846 def branches = "git branch --remote".execute().text.split("\n") |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
847 .findAll { it.contains('release') || it.contains('hotfix') } |
334
64a8d53c6d98
change how the version is parsed from git commands
Marc Davis <davis@ssdt-ohio.org>
parents:
331
diff
changeset
|
848 .collect { it.replaceAll('\\s+', ' ').split('/').last() - 'v' } |
331
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
849 .collect { new Version(*it.split('\\.')*.toInteger()) } |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
850 |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
851 def results = (branches + versions).sort { v1, v2 -> v2 <=> v1 } |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
852 if (results.isEmpty()) { |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
853 return new Version().nextSnapshot() |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
854 } else { |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
855 return results.first().nextSnapshot() |
7bc7c6c79d7c
check for current release and hotfix branches when looking for latest snapshot
Marc Davis <davis@ssdt-ohio.org>
parents:
326
diff
changeset
|
856 } |
311
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
857 } catch (ex) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
858 println ex |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
859 return new Version().nextSnapshot() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
860 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
861 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
862 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
863 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
864 def determineName() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
865 try { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
866 def branch = "git branch --show-current".execute().text.trim() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
867 return branch |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
868 } catch (ignored) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
869 return null |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
870 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
871 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
872 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
873 /** |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
874 * Try to determine the stream based on hgflow configs |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
875 * git-flow doesn't have a local config, so we may need to keep this |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
876 * file around just for the comparison. |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
877 * |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
878 * A new name for the file could help as well? |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
879 */ |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
880 void determineStream() { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
881 def flowConfig = new File('.hgflow').exists() ? new File('.hgflow') : new File('../.hgflow') |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
882 if (flowConfig.exists()) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
883 def flows = new Properties() |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
884 flows.load(flowConfig.newReader()) |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
885 flows.stringPropertyNames().each { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
886 if (!it.startsWith("[") && name.startsWith(flows.getProperty(it))) { |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
887 stream = it |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
888 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
889 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
890 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
891 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
892 |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
893 } |
69ef3d16fb19
add git specific versions of init20, init50, init70
Marc Davis <davis@ssdt-ohio.org>
parents:
diff
changeset
|
894 |