comparison init20.gradle @ 214:0ca4f3c952b7

DEP-11: add depency-lock plugin and a resolver to supply dynamic version based on branch. Cleanup metrics includes
author smith@nwoca.org
date Mon, 27 Jun 2016 19:50:00 +0100
parents 908950abd490
children 5bebb590b30e
comparison
equal deleted inserted replaced
213:40316e0cdef2 214:0ca4f3c952b7
1 import groovy.sql.Sql 1 import groovy.sql.Sql
2 import groovy.transform.ToString 2 import groovy.transform.ToString
3
4 buildscript {
5 repositories {
6 maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' }
7 maven { url 'http://repos.ssdt.nwoca.org/artifactory/ssdt-repo' }
8 }
9 dependencies {
10 classpath 'postgresql:postgresql:9.1-901.jdbc4'
11 classpath 'com.netflix.nebula:gradle-dependency-lock-plugin:4.3.0'
12 }
13 }
3 14
4 final GradleVersion gradleCurrent = GradleVersion.current() 15 final GradleVersion gradleCurrent = GradleVersion.current()
5 final GradleVersion gradleV20 = GradleVersion.version('2.0') 16 final GradleVersion gradleV20 = GradleVersion.version('2.0')
6 println "Gradle Version: $gradleCurrent" 17 println "Gradle Version: $gradleCurrent"
7 18
60 71
61 gradle.ext.branch = new BranchInfo(System.getenv('bamboo_planRepository_branch')) 72 gradle.ext.branch = new BranchInfo(System.getenv('bamboo_planRepository_branch'))
62 gradle.ext.branchName = gradle.branch.name 73 gradle.ext.branchName = gradle.branch.name
63 gradle.ext.branchStream = gradle.branch.stream 74 gradle.ext.branchStream = gradle.branch.stream
64 gradle.ext.branchHash = gradle.branch.hash 75 gradle.ext.branchHash = gradle.branch.hash
65 println "${gradle.hgRepositoryUrl} ${gradle.branch}" 76 println "${gradle.hgRepositoryUrl} ${gradle.branch} ${gradle.branch.imageId} ${gradle.branch.deployName}"
66 println "$gradle.runtimeInfo" 77 println "$gradle.runtimeInfo"
67 println gradle.branch
68 println gradle.branch.imageId
69 println gradle.branch.deployName
70 78
71 loadEnvironments() 79 loadEnvironments()
72 80
73 gradle.environment.put('hgRepositoryUrl', gradle.hgRepositoryUrl) 81 gradle.environment.put('hgRepositoryUrl', gradle.hgRepositoryUrl)
74 gradle.environment.put('branchName', gradle.branch.name) 82 gradle.environment.put('branchName', gradle.branch.name)
119 gradle.ext.ssdtGradlekitLocation = gradle.ext.has('ssdtGradlekitLocation') ? gradle.ssdtGradlekitLocation : 'http://hg.ssdt-ohio.org/ssdt/gradlekit/raw-file/tip' 127 gradle.ext.ssdtGradlekitLocation = gradle.ext.has('ssdtGradlekitLocation') ? gradle.ssdtGradlekitLocation : 'http://hg.ssdt-ohio.org/ssdt/gradlekit/raw-file/tip'
120 logger.info "applying SSDT artifactory Gradle Settings (bamboo: $gradle.bambooBuild host: $hostname)" 128 logger.info "applying SSDT artifactory Gradle Settings (bamboo: $gradle.bambooBuild host: $hostname)"
121 apply from: "${gradle.ssdtGradlekitLocation}/artifactory20.gradle" 129 apply from: "${gradle.ssdtGradlekitLocation}/artifactory20.gradle"
122 } 130 }
123 131
124
125 buildscript {
126 repositories {
127 maven { url 'http://repos.ssdt.nwoca.org/artifactory/ssdt-repo' }
128 }
129 dependencies {
130 classpath 'postgresql:postgresql:9.1-901.jdbc4'
131 }
132 }
133
134 apply from: "${gradle.ssdtDevelkitLocation}/metrics.gradle" 132 apply from: "${gradle.ssdtDevelkitLocation}/metrics.gradle"
135 133
136 rootProject.afterEvaluate { r -> 134 rootProject.afterEvaluate { r ->
137
138 135
139 if (gradle.bambooBuild && r.hasProperty('requireJavaVersion')) { 136 if (gradle.bambooBuild && r.hasProperty('requireJavaVersion')) {
140 gradle.runtimeInfo.requireJava( r.getProperty('requireJavaVersion') ) 137 gradle.runtimeInfo.requireJava( r.getProperty('requireJavaVersion') )
141 } 138 }
142 139
225 def findComponent(project, name) { 222 def findComponent(project, name) {
226 project.component.find { it.@name == name } 223 project.component.find { it.@name == name }
227 } 224 }
228 225
229 allprojects { 226 allprojects {
227
228 apply plugin: nebula.plugin.dependencylock.DependencyLockPlugin
229
230 configurations.all {
231 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
232 if (details.requested.group == 'org.ssdt_ohio' && !details.requested.version ) {
233 details.useVersion( "latest.${gradle.branch.defaultDependencyStatus}" )
234 }
235 if (details.requested.version == 'default') {
236 details.useVersion("latest.${gradle.branch.defaultDependencyStatus}" )
237 }
238 }
239 }
230 240
231 task cleanLocal(description: "removes all artifacts from developer's local repository") << { 241 task cleanLocal(description: "removes all artifacts from developer's local repository") << {
232 242
233 def local = project.repositories.find { it.name == 'local' } 243 def local = project.repositories.find { it.name == 'local' }
234 if (local) { 244 if (local) {
334 def void projectsEvaluated(Gradle gradle) { 344 def void projectsEvaluated(Gradle gradle) {
335 def ssdtArtifactory = 'http://repos.ssdt.nwoca.org/artifactory' 345 def ssdtArtifactory = 'http://repos.ssdt.nwoca.org/artifactory'
336 Project root = gradle.getRootProject() 346 Project root = gradle.getRootProject()
337 root.allprojects { 347 root.allprojects {
338 348
339
340 def thisProject = delegate 349 def thisProject = delegate
341 thisProject.status = 'integration' 350 thisProject.status = 'integration'
342 if (gradle.branchStream) { 351 if (gradle.branchStream) {
343 thisProject.status = 'integration' 352 thisProject.status = 'integration'
344 def fixupVersion = thisProject.version - ".SNAPSHOT" 353 def fixupVersion = thisProject.version - ".SNAPSHOT"
571 } 580 }
572 581
573 } 582 }
574 583
575 584
576
577 @ToString(includes=['name','shortName','buildVersion','imageId','deployName'],includeNames= true) 585 @ToString(includes=['name','shortName','buildVersion','imageId','deployName'],includeNames= true)
578 class BranchInfo { 586 class BranchInfo {
579 def name 587 def name
580 def stream = "none" 588 def stream = "none"
581 def buildNumber = "" 589 def buildNumber = ""
589 this.name = this.name.replace('@', '-') 597 this.name = this.name.replace('@', '-')
590 determineStream() 598 determineStream()
591 buildNumber = System.getenv('bamboo_buildNumber') ?: "" 599 buildNumber = System.getenv('bamboo_buildNumber') ?: ""
592 changeset = System.getenv('bamboo_planRepository_revision') ?: "" 600 changeset = System.getenv('bamboo_planRepository_revision') ?: ""
593 601
602 }
603
604 String getDefaultDependencyStatus() {
605 return stream in ['release','hotfix'] ? 'release' : 'integration'
594 } 606 }
595 607
596 def getShortName() { 608 def getShortName() {
597 def result = name.contains('/') ? name.split('/')[1] : name 609 def result = name.contains('/') ? name.split('/')[1] : name
598 } 610 }