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