Skip to content

Fix a dependency on kotlinx.serialization.core in JPMS for it to be truly optional #507

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

Merged
merged 4 commits into from
May 30, 2025
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
2 changes: 1 addition & 1 deletion core/jvm/java9/module-info.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module kotlinx.datetime {
requires transitive kotlin.stdlib;
requires transitive static kotlinx.serialization.core;
requires static kotlinx.serialization.core;

exports kotlinx.datetime;
exports kotlinx.datetime.serializers;
Expand Down
11 changes: 11 additions & 0 deletions integration-testing/jpms-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
kotlin("jvm")
}

java {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, it was required to enable java.modularity.inferModulePath to put compilation dependencies on the module path instead of class path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is it now on by default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it: https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_modular

Gradle will automatically put a Jar of your dependencies on the module path, instead of the classpath, if these three things are true

toolchain { languageVersion.set(JavaLanguageVersion.of(11)) }
}

dependencies {
api(project(":kotlinx-datetime"))
}
4 changes: 4 additions & 0 deletions integration-testing/jpms-test/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module my.jpms.test {
requires transitive kotlin.stdlib;
requires transitive kotlinx.datetime;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright 2019-2025 JetBrains s.r.o. and contributors.
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
*/

package my.jpms.test;

import kotlinx.datetime.*;

public class InitLocalDate {
LocalDate newLocalDate() {
return new LocalDate(2025, 3, 31);
}
}
14 changes: 8 additions & 6 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ include(":core")
project(":core").name = "kotlinx-datetime"
include(":timezones/full")
project(":timezones/full").name = "kotlinx-datetime-zoneinfo"
include(":serialization")
project(":serialization").name = "kotlinx-datetime-serialization"
include(":js-without-timezones")
project(":js-without-timezones").name = "kotlinx-datetime-js-test-without-timezones"
include(":js-with-timezones")
project(":js-with-timezones").name = "kotlinx-datetime-js-test-with-timezones"
include(":integration-testing/serialization")
project(":integration-testing/serialization").name = "kotlinx-datetime-serialization"
include(":integration-testing/js-without-timezones")
project(":integration-testing/js-without-timezones").name = "kotlinx-datetime-js-test-without-timezones"
include(":integration-testing/js-with-timezones")
project(":integration-testing/js-with-timezones").name = "kotlinx-datetime-js-test-with-timezones"
include(":integration-testing/jpms-test")
project(":integration-testing/jpms-test").name = "kotlinx-datetime-test-with-jpms"
include(":benchmarks")