From b90e1ab7ce461bd32ae18ff6236fb62127898ebb Mon Sep 17 00:00:00 2001 From: Matthew Nelson Date: Mon, 18 Mar 2024 12:41:49 -0400 Subject: [PATCH] Add JPMS support via Multi-Release Jar --- build-logic/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 +++++++ 9 files changed, 34 insertions(+), 6 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/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; +}