annotate init40-github.gradle @ 361:7b6d30651db7

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