feat: add jpms support with module-info.java#175
feat: add jpms support with module-info.java#175sgammon wants to merge 1 commit intoKotlin:masterfrom
module-info.java#175Conversation
- feat: add `module-info.java` - feat: add `Java9Modularity` used by other kotlinx projects - feat: build `core` project as multi-release jar - chore: upgrade gradle → `8.6` (to run under jvm21) - chore: general build cleanup (use kotlin for most build scripts) - chore: add gradle lockfiles and locking config - chore: add gradle dependency verification config
benchmarks/runner/build.gradle
Outdated
| implementation "org.jetbrains.kotlin:kotlin-stdlib" | ||
| implementation 'org.openjdk.jmh:jmh-core:1.21' | ||
| implementation libs.kotlin.stdlib | ||
| implementation libs.jmh.core |
There was a problem hiding this comment.
General build cleanup: moved dependencies to a version catalog.
| dependencyLocking { | ||
| lockAllConfigurations() | ||
| } |
There was a problem hiding this comment.
Dependency locking and verification were activated, but kept in lenient mode for now, to account for native dependency shift in CI.
| object Java9Modularity { | ||
| @JvmStatic | ||
| @JvmOverloads | ||
| fun Project.configureJava9ModuleInfo(multiRelease: Boolean = true) { |
core/build.gradle.kts
Outdated
| archivesBaseName = "kotlinx-collections-immutable" // doesn't work | ||
| archivesName = "kotlinx-collections-immutable" |
| @@ -1,3 +1,7 @@ | |||
| @file:OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class) | |||
| module kotlinx.collections.immutable { | ||
| requires java.base; | ||
| requires transitive kotlin.stdlib; | ||
| } |
There was a problem hiding this comment.
New module-info.java descriptor. I thought about adding it as kotlinx.collections.immutable.jvm, which is the suggested module name in IntelliJ; but I don't think users are using this value yet, because I can't locate it anywhere as an Automatic-Module-Name.
Thus, the format here matches other modules, like:
kotlinx.coroutines.[core|guava|...]kotlinx.serialization.[core|json|...]
| [versions] | ||
| kotlin-sdk = "1.9.22" | ||
| kotlinx-benchmark = "0.4.10" | ||
| kotlinx-validator = "0.13.2" | ||
| guava-testlib = "18.0" | ||
| jmh = "1.21" |
There was a problem hiding this comment.
New version catalog; other than updating kotlin-sdk to 1.9.22, no version changes were applied.
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip |
There was a problem hiding this comment.
Gradle upgrade → latest stable so that this project can run under JVM 21.
| pluginManagement { | ||
| repositories { |
There was a problem hiding this comment.
Rewrote this file as Kotlin because it helps a bit with build speed, since Groovy build scripts can't be build cached until Gradle 8.7, which is at RC2 (not yet released).
| repositories { | ||
| mavenCentral() | ||
| mavenLocal() | ||
| if (project.hasProperty("kotlin_repo_url")) { |
There was a problem hiding this comment.
Use the nullable findProperty method to check and retrieve property. The properties property performs a copy of the underlying map.
There was a problem hiding this comment.
Good catch, although this block wasn't supposed to make it in at all; I'll drop
|
Good PR, but there is a lot of housekeeping and the original intention gets lost in all the minutiae. |
ilya-g
left a comment
There was a problem hiding this comment.
While this project contains only one module where module-info should be added, it would be better to avoid introducing an included build with common logic like buildSrc - it complicates build and increases configuration time.
It's enough to add a compilation task directly in the core subproject, like it is done in kotlinx.datetime
We can refactor it later to shared build logic if we introduce another published module.
|
@daniel-jasinski Thank you for that review @ilya-g Okay, no problem. I will apply those changes. Thank you as well |
|
Is there still any progress on this issue? |
|
@sgammon do you plan continue working on this PR? |
Summary
This PR adds a
module-info.javadefinition, bringingkotlinx-collections-immutableto full JPMS support; downstream users can use the new module with the following directive:module-info.javaFixes and closes #157
Other changes
In general, the build was cleaned up, and Dependency Locking and Dependency Verification are now turned on, as is the case for other Kotlin projects.
Trying it out
This is still a draft because it is being tested downstream. If you would like to test this module, you can do so with:
build.gradle.ktsdependencies { implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.8-rc-1") }settings.gradle.ktsdependencyResolutionManagement { repositories { mavenCentral() // 👇 this repo maven { name = "elide-snapshots" url = uri("https://elide-snapshots.storage-download.googleapis.com/repository/v3/") } } }Changelog
module-info.javaJava9Modularityused by other kotlinx projectscoreproject as multi-release jar8.6(to run under jvm21)1.9.22