From 3d54636b321afb5acb23de2cc279d216b335ef71 Mon Sep 17 00:00:00 2001 From: Todd Ginsberg Date: Tue, 30 Jul 2024 09:20:44 -0400 Subject: [PATCH] Branch versioning changes + Move actual version to VERSION.txt + Change version to branch name with -SNAPSHOT when not on main or release branch + Print project and publish versions --- README.md | 4 ++-- VERSION.txt | 1 + build.gradle.kts | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 VERSION.txt diff --git a/README.md b/README.md index 2416578..df7382d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A library of useful [Stream Gatherers](https://openjdk.org/jeps/473) (custom int To use this library, add it as a dependency to your build. -*Maven* +**Maven** Add the following dependency to `pom.xml`. @@ -18,7 +18,7 @@ Add the following dependency to `pom.xml`. ``` -*Gradle* +**Gradle** Add the following dependency to `build.gradle` or `build.gradle.kts` diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..3373302 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +0.0.2-SNAPSHOT diff --git a/build.gradle.kts b/build.gradle.kts index db28c5c..d287c3a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,13 +11,13 @@ plugins { description = "An extra set of helpful Stream Gatherers for Java" group = "com.ginsberg" -version = "0.0.2-SNAPSHOT" -val gitBranch = gitBranch() -val gatherers4jVersion = if(gitBranch == "main" || gitBranch.startsWith("release/")) version.toString() - else "${gitBranch.substringAfter("/")}-SNAPSHOT" -println("Project Version: $gatherers4jVersion") +version = file("VERSION.txt").readLines().first() + @Suppress("PropertyName") val ENABLE_PREVIEW = "--enable-preview" +val gitBranch = gitBranch() +val gatherers4jVersion = if(gitBranch == "main" || gitBranch.startsWith("release/")) version.toString() + else "${gitBranch.substringAfterLast("/")}-SNAPSHOT" java { toolchain { @@ -120,6 +120,13 @@ tasks { addStringOption("Xdoclint:none", "-quiet") // TODO: Remove this when we've documented things } } + this.register("printVersion").configure { + dependsOn("publish") + doLast { + println("Project Version: $version") + println("Publish Version: $gatherers4jVersion") + } + } test { finalizedBy(jacocoTestReport) jvmArgs(ENABLE_PREVIEW)