Skip to content

Commit

Permalink
Add JPMS support via Multi-Release Jar (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
05nelsonm authored Mar 19, 2024
1 parent 5a03ed4 commit 8bb6a1b
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 12 deletions.
23 changes: 19 additions & 4 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 != 'windows-latest'
uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: 19

- name: Run macOS Tests
if: matrix.os == 'macos-latest'
Expand All @@ -65,7 +74,7 @@ jobs:
-PKMP_TARGETS="JVM,JS,MINGW_X64,WASM_JS,WASM_WASI"
emulator:
runs-on: macos-latest
runs-on: ubuntu-latest

strategy:
fail-fast: false
Expand All @@ -75,14 +84,20 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup JDK
uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: 19
java-version: 17

- name: Build
uses: gradle/gradle-build-action@v2
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,24 +13,27 @@
* 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,
explicitApi: Boolean = true,
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/hmac/hmac-md/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ plugins {
}

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

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

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

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

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

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

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

exports org.kotlincrypto.macs.hmac.sha3;
}
2 changes: 1 addition & 1 deletion library/hmac/hmac/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.macs.hmac", publish = true) {
common {
sourceSetMain {
dependencies {
Expand Down
8 changes: 8 additions & 0 deletions library/hmac/hmac/src/jvmMain/java9/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module org.kotlincrypto.macs.hmac {
requires kotlin.stdlib;
requires org.kotlincrypto.core;
requires org.kotlincrypto.core.digest;
requires transitive org.kotlincrypto.core.mac;

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

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

exports org.kotlincrypto.macs.kmac;
}

0 comments on commit 8bb6a1b

Please sign in to comment.