changeset 141:d3c09b4e3332

modify for hgflow. for feature branches, use timestamp for snapshots and resolve branch from ssdt-branches
author Dave Smith <smith@nwoca.org>
date Fri, 25 Oct 2013 17:31:10 +0100
parents 615ef3a8f0b8
children 45d2396e9fc8
files init.gradle
diffstat 1 files changed, 58 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/init.gradle	Thu Oct 17 02:02:26 2013 +0100
+++ b/init.gradle	Fri Oct 25 17:31:10 2013 +0100
@@ -19,11 +19,31 @@
 logger.info "Bamboo plan: ${gradle.bambooPlan}"
 
 
+gradle.ext.buildTimestamp = System.currentTimeMillis().toString().padLeft(14,'0')
+
 gradle.ext.hgRepositoryUrl = ""
+gradle.ext.branchName = ""
+gradle.ext.branchStream = ""
 try {
-   gradle.ext.hgRepositoryUrl = "hg path".execute().text.split('=')[1].trim()
-} catch (e) {}
+   gradle.ext.branchName = "hg branch".execute().text.trim()
+   gradle.ext.hgRepositoryUrl = ("hg path".execute().text.split('=') ?: ['',''] )[1].trim()
+} catch (e) {  }
+
 
+if (file('.hgflow').exists()) {
+	def flows = new Properties()
+	flows.load(file('.hgflow').newReader())
+	flows.stringPropertyNames().each {
+		if (!it.startsWith("[") && gradle.ext.branchName.startsWith(flows.getProperty(it))) {
+			gradle.ext.branchStream = it
+		}
+	
+	}
+}
+gradle.environment.put('hgRepositoryUrl',gradle.hgRepositoryUrl)
+gradle.environment.put('branchName',gradle.branchName)
+gradle.environment.put('branchStream',gradle.branchStream)
+	
 rootProject.ext.indyCapable = {
     boolean capable = true
     try {
@@ -186,13 +206,32 @@
         def ssdtArtifactory = 'http://repos.ssdt.nwoca.org/artifactory'
         Project root = gradle.getRootProject()       
         root.allprojects {
+		
+		
                
-            def thisProject = delegate        
+            def thisProject = delegate
+			thisProject.status = 'integration'
+			if (gradle.branchStream) {
+				thisProject.status = 'integration'
+				def fixupVersion = thisProject.version - ".SNAPSHOT"
+				if ( gradle.branchStream == 'feature' ) {
+					fixupVersion = fixupVersion + "-" + gradle.buildTimestamp
+				}
+				if ( gradle.branchStream == 'develop' ) {
+					fixupVersion = fixupVersion + ".SNAPSHOT"
+				}				
+				if ( gradle.branchStream in ['production','release'] ) {
+					thisProject.status = 'release'
+				}
+				thisProject.version = fixupVersion
+			}
+			
             configurations.all {
                 resolutionStrategy.cacheChangingModulesFor 60 * 60 * 8, 'seconds'
                 resolutionStrategy.cacheDynamicVersionsFor 60 * 60 * 8, 'seconds'
             }        
             repositories {
+			
                 if (!gradle.bambooBuild) {                         
                     add(new org.apache.ivy.plugins.resolver.FileSystemResolver()) {
                         name = 'local'
@@ -205,6 +244,21 @@
                         force = true
                     }                       
                 }                   
+				
+				
+				if(gradle.branchStream == 'feature') {
+					add(new org.apache.ivy.plugins.resolver.URLResolver()) {
+						name = 'ssdt-branches'
+						m2compatible =  false
+						def url = "${ssdtArtifactory}/ssdt-branches"
+						def filter = ";ssdt-branch.branchName+=${gradle.branchName}"
+						addArtifactPattern("${url}/[organization]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]${filter}")
+						addIvyPattern("${url}/[organization]/[module]/ivy-[revision].xml;${filter}")
+						checkmodified = true
+						changingMatcher = 'regexp'
+						changingPattern = /\d{14}/
+					}
+				}
 
                 add(new org.apache.ivy.plugins.resolver.URLResolver()) {
                     name = 'ssdt-snapshots'
@@ -216,7 +270,7 @@
                     checkmodified = true
                     changingMatcher = 'regexp'
                     changingPattern = '.*SNAPSHOT'
-                   }
+                }
 
                 add(new org.apache.ivy.plugins.resolver.URLResolver()) {
                     name = 'ssdt-releases'