Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch and publication version changes #12

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
26 changes: 25 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 @@ -10,10 +11,13 @@ plugins {

description = "An extra set of helpful Stream Gatherers for Java"
group = "com.ginsberg"
version = "0.0.2-SNAPSHOT"
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 @@ -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 @@ -97,6 +102,7 @@ tasks {
withType<JavaCompile> {
options.compilerArgs.add(ENABLE_PREVIEW)
}

jacocoTestReport {
dependsOn(test)
}
Expand All @@ -115,9 +121,27 @@ tasks {
addStringOption("Xdoclint:none", "-quiet") // TODO: Remove this when we've documented things
}
}
publish {
doLast {
println("Project Version: $version")
println("Publish Version: $gatherers4jVersion")
}
}
test {
finalizedBy(jacocoTestReport)
jvmArgs(ENABLE_PREVIEW)
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()
}