Skip to content

Commit

Permalink
fix task configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
farrell-m committed May 16, 2024
1 parent dea2206 commit b97615a
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.quality.CheckstylePlugin
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
import org.gradle.api.tasks.testing.Test
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.testing.jacoco.plugins.JacocoPlugin
Expand All @@ -21,6 +23,7 @@ class LaaCcmsJavaGradlePlugin implements Plugin<Project> {
target.pluginManager.apply JacocoPlugin
target.pluginManager.apply VersionsPlugin
target.pluginManager.apply CheckstylePlugin
target.pluginManager.apply MavenPublishPlugin

target.java {
toolchain.languageVersion.set(JavaLanguageVersion.of(JAVA_VERSION))
Expand Down Expand Up @@ -71,16 +74,16 @@ class LaaCcmsJavaGradlePlugin implements Plugin<Project> {
showViolations = true
}

target.tasks.withType(AbstractPublishToMaven) {
target.tasks.withType(AbstractPublishToMaven).configureEach {
doLast {
logger.lifecycle("Published Maven artifact: " +
"${publication.groupId}:${publication.artifactId}:${publication.version}")
}
}

//used for deploying snapshot packages
target.task("updateSnapshotVersion")
.doLast(task -> {
target.tasks.register("updateSnapshotVersion") {
doLast(task -> {
def gitHash = "git rev-parse --short HEAD".execute().text.trim()
def propertiesFile = file('gradle.properties')
def properties = new Properties()
Expand All @@ -89,9 +92,9 @@ class LaaCcmsJavaGradlePlugin implements Plugin<Project> {
def currentVersion = properties.getProperty('version')
def newVersion = currentVersion.replace('-SNAPSHOT', "-${gitHash}-SNAPSHOT")
properties.setProperty('version', newVersion)

properties.store(propertiesFile.newWriter(), null)
}
)
}
}
}

0 comments on commit b97615a

Please sign in to comment.