From 28aa6dc244e9fca6a71fc991a4674a5c27d1f20a Mon Sep 17 00:00:00 2001 From: zero88 Date: Sat, 22 Jun 2024 15:47:55 +0700 Subject: [PATCH] feat(gradle): Append jvm variant as build version to support multiple java versions #216 --- .github/workflows/jooqx.yml | 2 +- build.gradle.kts | 28 ++++++++++++---------------- core/build.gradle.kts | 9 --------- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/.github/workflows/jooqx.yml b/.github/workflows/jooqx.yml index b3e7f9e6..ce48b7b5 100644 --- a/.github/workflows/jooqx.yml +++ b/.github/workflows/jooqx.yml @@ -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 }} diff --git a/build.gradle.kts b/build.gradle.kts index 8a310ffd..1e6c1d61 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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) @@ -105,17 +112,6 @@ subprojects { withType { enabled = project != rootProject && project.path !in skipPublish } - - withType { - archiveClassifier.set( - when (name) { - "testFixturesJar" -> "test-fixtures$artifactClassifier" - "javadocJar" -> "javadoc$artifactClassifier" - "sourcesJar" -> "sources$artifactClassifier" - else -> artifactClassifier.replace("-", "") - } - ) - } } } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 9ff77a39..273fbc08 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -103,13 +103,4 @@ tasks { title = "jOOQx Testing ${project.version} API" } - withType { - // 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") - } - } - } }