From 30a2c570a3662ae2820e3ccddf510a4eb1d9d9cd Mon Sep 17 00:00:00 2001 From: farrell-m Date: Fri, 17 May 2024 14:21:51 +0100 Subject: [PATCH] avoid duplicate task creation --- .../uk/gov/laa/ccms/gradle/LaaCcmsJavaGradlePlugin.groovy | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/laa-ccms-java-gradle-plugin/src/main/groovy/uk/gov/laa/ccms/gradle/LaaCcmsJavaGradlePlugin.groovy b/laa-ccms-java-gradle-plugin/src/main/groovy/uk/gov/laa/ccms/gradle/LaaCcmsJavaGradlePlugin.groovy index 4600ca4..af87ca9 100644 --- a/laa-ccms-java-gradle-plugin/src/main/groovy/uk/gov/laa/ccms/gradle/LaaCcmsJavaGradlePlugin.groovy +++ b/laa-ccms-java-gradle-plugin/src/main/groovy/uk/gov/laa/ccms/gradle/LaaCcmsJavaGradlePlugin.groovy @@ -155,8 +155,9 @@ class LaaCcmsJavaGradlePlugin implements Plugin { } // Used for deploying snapshot packages - target.rootProject.tasks.register("updateSnapshotVersion") { - doLast(task -> { + if (target.rootProject.tasks.findByName('updateSnapshotVersion') == null) { + target.rootProject.tasks.register("updateSnapshotVersion") { + doLast(task -> { def gitHash = "git rev-parse --short HEAD".execute().text.trim() def propertiesFile = target.rootProject.file('gradle.properties') def properties = new Properties() @@ -167,7 +168,8 @@ class LaaCcmsJavaGradlePlugin implements Plugin { properties.setProperty('version', newVersion) properties.store(propertiesFile.newWriter(), null) } - ) + ) + } } } }