annotate init70-github.gradle @ 349:45fc06cbb6b2

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