Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JPMS support via Multi-Release Jar #59

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/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.hash.md", publish = true) {
common {
sourceSetMain {
dependencies {
Expand Down
7 changes: 7 additions & 0 deletions library/md/src/jvmMain/java9/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module org.kotlincrypto.hash.md {
requires kotlin.stdlib;
requires org.kotlincrypto.core;
requires org.kotlincrypto.core.digest;

exports org.kotlincrypto.hash.md;
}
2 changes: 1 addition & 1 deletion library/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.hash.sha1", publish = true) {
common {
sourceSetMain {
dependencies {
Expand Down
8 changes: 8 additions & 0 deletions library/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.hash.sha1 {
requires kotlin.stdlib;
requires org.kotlincrypto.core;
requires org.kotlincrypto.core.digest;

exports org.kotlincrypto.hash.sha1;
}
2 changes: 1 addition & 1 deletion library/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.hash.sha2", publish = true) {
common {
sourceSetMain {
dependencies {
Expand Down
8 changes: 8 additions & 0 deletions library/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.hash.sha2 {
requires kotlin.stdlib;
requires org.kotlincrypto.core;
requires org.kotlincrypto.core.digest;

exports org.kotlincrypto.hash.sha2;
}
2 changes: 1 addition & 1 deletion library/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.hash.sha3", publish = true) {
common {
sourceSetMain {
dependencies {
Expand Down
11 changes: 11 additions & 0 deletions library/sha3/src/jvmMain/java9/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@SuppressWarnings("JavaModuleNaming")
module org.kotlincrypto.hash.sha3 {
requires kotlin.stdlib;
requires org.kotlincrypto.core;
requires org.kotlincrypto.core.digest;
requires org.kotlincrypto.core.xof;
requires org.kotlincrypto.endians;
requires org.kotlincrypto.sponges.keccak;

exports org.kotlincrypto.hash.sha3;
}
Loading