Skip to content

Commit

Permalink
Add JPMS support via Multi-Release Jar
Browse files Browse the repository at this point in the history
  • Loading branch information
05nelsonm committed Mar 18, 2024
1 parent ff04c4e commit b90e1ab
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 6 deletions.
7 changes: 5 additions & 2 deletions build-logic/src/main/kotlin/-KmpConfigurationExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,26 @@
* 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
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<KmpConfigurationContainerDsl>
) {
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()
Expand Down
2 changes: 1 addition & 1 deletion library/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ plugins {
}

kmpConfiguration {
configureShared(publish = true) {}
configureShared(java9ModuleName = "org.kotlincrypto.core", publish = true) {}
}
5 changes: 5 additions & 0 deletions library/common/src/jvmMain/java9/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module org.kotlincrypto.core {
requires kotlin.stdlib;

exports org.kotlincrypto.core;
}
2 changes: 1 addition & 1 deletion library/digest/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
}

kmpConfiguration {
configureShared(publish = true) {
configureShared(java9ModuleName = "org.kotlincrypto.core.digest", publish = true) {
common {
sourceSetMain {
dependencies {
Expand Down
7 changes: 7 additions & 0 deletions library/digest/src/jvmMain/java9/module-info.java
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion library/mac/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
}

kmpConfiguration {
configureShared(publish = true) {
configureShared(java9ModuleName = "org.kotlincrypto.core.mac", publish = true) {
common {
sourceSetMain {
dependencies {
Expand Down
6 changes: 6 additions & 0 deletions library/mac/src/jvmMain/java9/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module org.kotlincrypto.core.mac {
requires kotlin.stdlib;
requires org.kotlincrypto.core;

exports org.kotlincrypto.core.mac;
}
2 changes: 1 addition & 1 deletion library/xof/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
}

kmpConfiguration {
configureShared(publish = true) {
configureShared(java9ModuleName = "org.kotlincrypto.core.xof", publish = true) {
common {
sourceSetMain {
dependencies {
Expand Down
7 changes: 7 additions & 0 deletions library/xof/src/jvmMain/java9/module-info.java
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit b90e1ab

Please sign in to comment.