annotate init40-git.gradle @ 338:0befe249fc6f

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