annotate init40pom.gradle @ 310:7bf282e58ce7

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