Skip to content

Commit

Permalink
feat(gradle): Append jvm variant as build version to support multiple…
Browse files Browse the repository at this point in the history
… java versions #216
  • Loading branch information
zero88 committed Jun 22, 2024
1 parent 426587e commit 28aa6dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/jooqx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
os: [ 'ubuntu-latest' ]
with:
profile: 'jooqx'
version: ${{ matrix.java == '17' && needs.context.outputs.version || format('{0}-jvm8', needs.context.outputs.version) }}
version: ${{ needs.context.outputs.version }}
semanticVersion: ${{ needs.context.outputs.semanticVersion }}
hashVersion: ${{ needs.context.outputs.commitId }}
isRelease: ${{ needs.context.outputs.isRelease }}
Expand Down
28 changes: 12 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,20 @@ subprojects {
}
}
}
val artifactClassifier = when (jvmRuntime) {
"8" -> if (jvmRelease == "8") "" else "-jvm8"
"11" -> if (jvmRelease == "11") "" else "-jvm11"
"17" -> if (jvmRelease == "17") "" else "-jvm17"
"21" -> if (jvmRelease == "21") "" else "-jvm21"

val buildVersion = when (jvmRuntime) {
"8" -> if (jvmRelease == "8") "" else "+jvm8"
"11" -> if (jvmRelease == "11") "" else "+jvm11"
"17" -> if (jvmRelease == "17") "" else "+jvm17"
"21" -> if (jvmRelease == "21") "" else "+jvm21"
else -> throw IllegalArgumentException("Unknown version $jvmRuntime")
}
val semanticVersion = prop(project, "semanticVersion", "")
version = when (semanticVersion) {
"-SNAPSHOT" -> project.version.toString().replace(semanticVersion, buildVersion + semanticVersion)
"" -> project.version.toString() + buildVersion
else -> project.version.toString().replace(semanticVersion, semanticVersion + buildVersion)
}

dependencies {
compileOnly(rootProject.libs.jetbrainsAnnotations)
Expand Down Expand Up @@ -105,17 +112,6 @@ subprojects {
withType<AbstractPublishToMaven> {
enabled = project != rootProject && project.path !in skipPublish
}

withType<Jar> {
archiveClassifier.set(
when (name) {
"testFixturesJar" -> "test-fixtures$artifactClassifier"
"javadocJar" -> "javadoc$artifactClassifier"
"sourcesJar" -> "sources$artifactClassifier"
else -> artifactClassifier.replace("-", "")
}
)
}
}
}

Expand Down
9 changes: 0 additions & 9 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,4 @@ tasks {
title = "jOOQx Testing ${project.version} API"
}

withType<Jar> {
// need to override in here, since at root project, test-fixtures is not yet recognized
if (name == "testFixturesJar") {
when (JavaVersion.current().majorVersion) {
"8" -> archiveClassifier.set("test-fixtures-jvm8")
"11" -> archiveClassifier.set("test-fixtures-jvm11")
}
}
}
}

0 comments on commit 28aa6dc

Please sign in to comment.