Skip to content

Commit

Permalink
Branch versioning changes
Browse files Browse the repository at this point in the history
+ 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
  • Loading branch information
tginsberg committed Jul 30, 2024
1 parent 81da2b2 commit 3d54636
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand All @@ -18,7 +18,7 @@ Add the following dependency to `pom.xml`.
</dependency>
```

*Gradle*
**Gradle**

Add the following dependency to `build.gradle` or `build.gradle.kts`

Expand Down
1 change: 1 addition & 0 deletions VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.2-SNAPSHOT
17 changes: 12 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3d54636

Please sign in to comment.