diff init20.gradle @ 256:91e05187fd79

split release branch creation and dependency lock into separate steps. Force correct deletion of global lock
author smith@nwoca.org
date Wed, 06 Jun 2018 23:15:28 +0100
parents 37e1c910c8f5
children 70b500eef001
line wrap: on
line diff
--- a/init20.gradle	Wed May 30 21:09:51 2018 +0100
+++ b/init20.gradle	Wed Jun 06 23:15:28 2018 +0100
@@ -10,7 +10,7 @@
     }
     dependencies {
         classpath 'postgresql:postgresql:9.1-901.jdbc4'
-        classpath  'com.netflix.nebula:gradle-dependency-lock-plugin:5.0.2'
+        classpath  'com.netflix.nebula:gradle-dependency-lock-plugin:5.0.6'
     }
 }
 
@@ -165,8 +165,9 @@
 
     dependencyLock {
         globalLockFile =  gradle.branch.isRelease() ? 'release.lock' : 'global.lock'
-        includeTransitives = true
+        includeTransitives = true       
     }
+    
     configurations.all {
         resolutionStrategy.cacheChangingModulesFor gradle.cacheTimeout, 'seconds'
         resolutionStrategy.cacheDynamicVersionsFor gradle.cacheTimeout, 'seconds'
@@ -292,8 +293,45 @@
 
 rootProject.afterEvaluate {
 
-    tasks.addRule("release{Major|Minor|Patch|n.n.n}: create release branch") { String taskName ->
+    tasks.addRule("release{Major|Minor|Patch|n.n.n|Lock}: create release branch or update release Lock file") { String taskName ->
+
+        if (taskName == 'releaseLock') {
+
+            if (!gradle.branch.isRelease()) {
+                throw new BuildCancelledException("releaseLock is only valid on release or hotfix branch.")
+            }
+        
+            dependencyLock.globalLockFile =  'release.lock' 
+                       
+            task('doCommitLock') {
+				doLast {
+					println 'hg status'.execute().text
+					println 'hg commit release.lock -A -m "lock dynamic dependencies for release"'.execute().text
+				}
+            }
 
+                        
+            task('doForceDeleteLock') {
+				doLast {
+                    println "deleting $dependencyLock.globalLockFile"
+                    rootProject.file(dependencyLock.globalLockFile).delete()
+				}
+            }
+
+            
+            def branchTasks = ['deleteGlobalLock', 'doForceDeleteLock', 'generateGlobalLock', 'saveGlobalLock', 'doCommitLock']
+
+            task(taskName) {
+                dependsOn branchTasks
+            }
+
+            branchTasks.tail().inject(branchTasks.head()) { a, b ->
+                tasks[b].mustRunAfter a
+                b
+            }
+
+        }
+           
         def matcher = (taskName =~ /^release(Major|Minor|Patch|\d{1,3}\.\d{1,3}\.\d{1,3})$/)
         if (matcher.matches()) {
 
@@ -331,17 +369,15 @@
                     
                     setBranchInfo()
                     
+					println "-" * 60
+                    println " Be sure to execute 'releaseLock' task to update the release.lock file before proceeding."
+					println "-" * 60
+                    
 				}
             } 
 
-            task('doCommitLock') {
-				doLast {
-					println 'hg status'.execute().text
-					println 'hg commit release.lock -A -m "lock dynamic dependencies for release"'.execute().text
-				}
-            }
 
-            def branchTasks = ['doReleaseBranch', 'deleteGlobalLock', 'generateGlobalLock', 'saveGlobalLock', 'doCommitLock']
+            def branchTasks = ['doReleaseBranch']
 
             task(taskName) {
                 dependsOn branchTasks