comparison 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
comparison
equal deleted inserted replaced
255:37e1c910c8f5 256:91e05187fd79
8 maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' } 8 maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' }
9 maven { url 'http://repos.ssdt.nwoca.org/artifactory/ssdt-repo' } 9 maven { url 'http://repos.ssdt.nwoca.org/artifactory/ssdt-repo' }
10 } 10 }
11 dependencies { 11 dependencies {
12 classpath 'postgresql:postgresql:9.1-901.jdbc4' 12 classpath 'postgresql:postgresql:9.1-901.jdbc4'
13 classpath 'com.netflix.nebula:gradle-dependency-lock-plugin:5.0.2' 13 classpath 'com.netflix.nebula:gradle-dependency-lock-plugin:5.0.6'
14 } 14 }
15 } 15 }
16 16
17 final GradleVersion gradleCurrent = GradleVersion.current() 17 final GradleVersion gradleCurrent = GradleVersion.current()
18 final GradleVersion gradleV20 = GradleVersion.version('2.0') 18 final GradleVersion gradleV20 = GradleVersion.version('2.0')
163 163
164 apply plugin: nebula.plugin.dependencylock.DependencyLockPlugin 164 apply plugin: nebula.plugin.dependencylock.DependencyLockPlugin
165 165
166 dependencyLock { 166 dependencyLock {
167 globalLockFile = gradle.branch.isRelease() ? 'release.lock' : 'global.lock' 167 globalLockFile = gradle.branch.isRelease() ? 'release.lock' : 'global.lock'
168 includeTransitives = true 168 includeTransitives = true
169 } 169 }
170
170 configurations.all { 171 configurations.all {
171 resolutionStrategy.cacheChangingModulesFor gradle.cacheTimeout, 'seconds' 172 resolutionStrategy.cacheChangingModulesFor gradle.cacheTimeout, 'seconds'
172 resolutionStrategy.cacheDynamicVersionsFor gradle.cacheTimeout, 'seconds' 173 resolutionStrategy.cacheDynamicVersionsFor gradle.cacheTimeout, 'seconds'
173 } 174 }
174 configurations.all { 175 configurations.all {
290 291
291 } 292 }
292 293
293 rootProject.afterEvaluate { 294 rootProject.afterEvaluate {
294 295
295 tasks.addRule("release{Major|Minor|Patch|n.n.n}: create release branch") { String taskName -> 296 tasks.addRule("release{Major|Minor|Patch|n.n.n|Lock}: create release branch or update release Lock file") { String taskName ->
296 297
298 if (taskName == 'releaseLock') {
299
300 if (!gradle.branch.isRelease()) {
301 throw new BuildCancelledException("releaseLock is only valid on release or hotfix branch.")
302 }
303
304 dependencyLock.globalLockFile = 'release.lock'
305
306 task('doCommitLock') {
307 doLast {
308 println 'hg status'.execute().text
309 println 'hg commit release.lock -A -m "lock dynamic dependencies for release"'.execute().text
310 }
311 }
312
313
314 task('doForceDeleteLock') {
315 doLast {
316 println "deleting $dependencyLock.globalLockFile"
317 rootProject.file(dependencyLock.globalLockFile).delete()
318 }
319 }
320
321
322 def branchTasks = ['deleteGlobalLock', 'doForceDeleteLock', 'generateGlobalLock', 'saveGlobalLock', 'doCommitLock']
323
324 task(taskName) {
325 dependsOn branchTasks
326 }
327
328 branchTasks.tail().inject(branchTasks.head()) { a, b ->
329 tasks[b].mustRunAfter a
330 b
331 }
332
333 }
334
297 def matcher = (taskName =~ /^release(Major|Minor|Patch|\d{1,3}\.\d{1,3}\.\d{1,3})$/) 335 def matcher = (taskName =~ /^release(Major|Minor|Patch|\d{1,3}\.\d{1,3}\.\d{1,3})$/)
298 if (matcher.matches()) { 336 if (matcher.matches()) {
299 337
300 dependencyLock.globalLockFile = 'release.lock' 338 dependencyLock.globalLockFile = 'release.lock'
301 339
329 println "hg flow ${releaseStream} start v${releaseVersion} --dirty".execute().text 367 println "hg flow ${releaseStream} start v${releaseVersion} --dirty".execute().text
330 println "hg update ${releaseStream}/v${releaseVersion}".execute().text 368 println "hg update ${releaseStream}/v${releaseVersion}".execute().text
331 369
332 setBranchInfo() 370 setBranchInfo()
333 371
372 println "-" * 60
373 println " Be sure to execute 'releaseLock' task to update the release.lock file before proceeding."
374 println "-" * 60
375
334 } 376 }
335 } 377 }
336 378
337 task('doCommitLock') { 379
338 doLast { 380 def branchTasks = ['doReleaseBranch']
339 println 'hg status'.execute().text
340 println 'hg commit release.lock -A -m "lock dynamic dependencies for release"'.execute().text
341 }
342 }
343
344 def branchTasks = ['doReleaseBranch', 'deleteGlobalLock', 'generateGlobalLock', 'saveGlobalLock', 'doCommitLock']
345 381
346 task(taskName) { 382 task(taskName) {
347 dependsOn branchTasks 383 dependsOn branchTasks
348 } 384 }
349 385