Skip to content

Commit

Permalink
Testing versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
tginsberg committed Jul 30, 2024
1 parent 43ff268 commit 81da2b2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import java.io.IOException
import java.net.URI

plugins {
Expand All @@ -11,7 +12,10 @@ 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")
@Suppress("PropertyName")
val ENABLE_PREVIEW = "--enable-preview"

Expand Down Expand Up @@ -46,6 +50,7 @@ publishing {
pom {
name = "Gatherers4J"
description = project.description
version = gatherers4jVersion
url = "https://github.com/tginsberg/gatherers4j"
organization {
name = "com.ginsberg"
Expand Down Expand Up @@ -121,3 +126,14 @@ tasks {
useJUnitPlatform()
}
}

fun gitBranch(): String =
ProcessBuilder("git rev-parse --abbrev-ref HEAD".split(" "))
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
.run {
val error = errorStream.bufferedReader().readText()
if (error.isNotEmpty()) throw IOException(error)
inputStream.bufferedReader().readText().trim()
}

0 comments on commit 81da2b2

Please sign in to comment.