Skip to content

Commit

Permalink
Add JPMS support via Multi-Release Jar (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
05nelsonm authored Mar 18, 2024
1 parent ff04c4e commit 2bd2ac9
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 8 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
distribution: 'zulu'
java-version: 17
java-version: 11

- name: Setup JDK 19
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: 19

- name: Run macOS Tests
if: matrix.os == 'macos-latest'
Expand Down
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 2bd2ac9

Please sign in to comment.