From 2bd2ac974146f30c3bf9db6699fd47c7d4b3de94 Mon Sep 17 00:00:00 2001 From: Matthew Nelson Date: Mon, 18 Mar 2024 13:25:00 -0400 Subject: [PATCH] Add `JPMS` support via Multi-Release Jar (#56) --- .github/workflows/CI.yml | 13 +++++++++++-- .../src/main/kotlin/-KmpConfigurationExtension.kt | 7 +++++-- library/common/build.gradle.kts | 2 +- library/common/src/jvmMain/java9/module-info.java | 5 +++++ library/digest/build.gradle.kts | 2 +- library/digest/src/jvmMain/java9/module-info.java | 7 +++++++ library/mac/build.gradle.kts | 2 +- library/mac/src/jvmMain/java9/module-info.java | 6 ++++++ library/xof/build.gradle.kts | 2 +- library/xof/src/jvmMain/java9/module-info.java | 7 +++++++ 10 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 library/common/src/jvmMain/java9/module-info.java create mode 100644 library/digest/src/jvmMain/java9/module-info.java create mode 100644 library/mac/src/jvmMain/java9/module-info.java create mode 100644 library/xof/src/jvmMain/java9/module-info.java diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5596869..d9ac4d0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -42,11 +42,20 @@ jobs: key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('gradle/libs.versions.toml') }} restore-keys: ${{ runner.os }}-gradle-caches- - - name: Setup JDK + # Windows does not build ANDROID, but needs Java 11 for JPMS Multi-Release Jar build + - name: Setup JDK 11 + if: matrix.os == 'windows-latest' uses: actions/setup-java@v3.4.0 with: distribution: 'zulu' - java-version: 17 + java-version: 11 + + - name: Setup JDK 19 + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + uses: actions/setup-java@v3.4.0 + with: + distribution: 'zulu' + java-version: 19 - name: Run macOS Tests if: matrix.os == 'macos-latest' diff --git a/build-logic/src/main/kotlin/-KmpConfigurationExtension.kt b/build-logic/src/main/kotlin/-KmpConfigurationExtension.kt index 3a3ed84..a5fd5db 100644 --- a/build-logic/src/main/kotlin/-KmpConfigurationExtension.kt +++ b/build-logic/src/main/kotlin/-KmpConfigurationExtension.kt @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ +import io.matthewnelson.kmp.configuration.ExperimentalKmpConfigurationApi import io.matthewnelson.kmp.configuration.extension.KmpConfigurationExtension import io.matthewnelson.kmp.configuration.extension.container.target.KmpConfigurationContainerDsl import org.gradle.api.Action @@ -20,16 +21,18 @@ import org.gradle.api.JavaVersion import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl fun KmpConfigurationExtension.configureShared( + java9ModuleName: String? = null, publish: Boolean = false, action: Action ) { configure { jvm { - target { withJava() } - kotlinJvmTarget = JavaVersion.VERSION_1_8 compileSourceCompatibility = JavaVersion.VERSION_1_8 compileTargetCompatibility = JavaVersion.VERSION_1_8 + + @OptIn(ExperimentalKmpConfigurationApi::class) + java9MultiReleaseModuleInfo(java9ModuleName) } js() diff --git a/library/common/build.gradle.kts b/library/common/build.gradle.kts index 6092041..d99192c 100644 --- a/library/common/build.gradle.kts +++ b/library/common/build.gradle.kts @@ -18,5 +18,5 @@ plugins { } kmpConfiguration { - configureShared(publish = true) {} + configureShared(java9ModuleName = "org.kotlincrypto.core", publish = true) {} } diff --git a/library/common/src/jvmMain/java9/module-info.java b/library/common/src/jvmMain/java9/module-info.java new file mode 100644 index 0000000..aa8ea63 --- /dev/null +++ b/library/common/src/jvmMain/java9/module-info.java @@ -0,0 +1,5 @@ +module org.kotlincrypto.core { + requires kotlin.stdlib; + + exports org.kotlincrypto.core; +} diff --git a/library/digest/build.gradle.kts b/library/digest/build.gradle.kts index ba8db03..7376662 100644 --- a/library/digest/build.gradle.kts +++ b/library/digest/build.gradle.kts @@ -18,7 +18,7 @@ plugins { } kmpConfiguration { - configureShared(publish = true) { + configureShared(java9ModuleName = "org.kotlincrypto.core.digest", publish = true) { common { sourceSetMain { dependencies { diff --git a/library/digest/src/jvmMain/java9/module-info.java b/library/digest/src/jvmMain/java9/module-info.java new file mode 100644 index 0000000..445ab30 --- /dev/null +++ b/library/digest/src/jvmMain/java9/module-info.java @@ -0,0 +1,7 @@ +module org.kotlincrypto.core.digest { + requires kotlin.stdlib; + requires org.kotlincrypto.core; + + exports org.kotlincrypto.core.digest; + exports org.kotlincrypto.core.digest.internal; +} diff --git a/library/mac/build.gradle.kts b/library/mac/build.gradle.kts index ba8db03..46d0797 100644 --- a/library/mac/build.gradle.kts +++ b/library/mac/build.gradle.kts @@ -18,7 +18,7 @@ plugins { } kmpConfiguration { - configureShared(publish = true) { + configureShared(java9ModuleName = "org.kotlincrypto.core.mac", publish = true) { common { sourceSetMain { dependencies { diff --git a/library/mac/src/jvmMain/java9/module-info.java b/library/mac/src/jvmMain/java9/module-info.java new file mode 100644 index 0000000..1885b12 --- /dev/null +++ b/library/mac/src/jvmMain/java9/module-info.java @@ -0,0 +1,6 @@ +module org.kotlincrypto.core.mac { + requires kotlin.stdlib; + requires org.kotlincrypto.core; + + exports org.kotlincrypto.core.mac; +} diff --git a/library/xof/build.gradle.kts b/library/xof/build.gradle.kts index dabecce..34b27f1 100644 --- a/library/xof/build.gradle.kts +++ b/library/xof/build.gradle.kts @@ -18,7 +18,7 @@ plugins { } kmpConfiguration { - configureShared(publish = true) { + configureShared(java9ModuleName = "org.kotlincrypto.core.xof", publish = true) { common { sourceSetMain { dependencies { diff --git a/library/xof/src/jvmMain/java9/module-info.java b/library/xof/src/jvmMain/java9/module-info.java new file mode 100644 index 0000000..5f5c098 --- /dev/null +++ b/library/xof/src/jvmMain/java9/module-info.java @@ -0,0 +1,7 @@ +module org.kotlincrypto.core.xof { + requires kotlin.stdlib; + requires org.kotlincrypto.core; + requires org.kotlincrypto.endians; + + exports org.kotlincrypto.core.xof; +}