Skip to content

Upgrade to kotlinx-serialization 1.9.0 and Kotlin 2.2.21#362

Open
rjwalters wants to merge 2 commits into
orchestr7:mainfrom
rjwalters:upgrade/kotlinx-serialization-1.9.0
Open

Upgrade to kotlinx-serialization 1.9.0 and Kotlin 2.2.21#362
rjwalters wants to merge 2 commits into
orchestr7:mainfrom
rjwalters:upgrade/kotlinx-serialization-1.9.0

Conversation

@rjwalters
Copy link
Copy Markdown
Contributor

Summary

This PR upgrades the project to kotlinx-serialization 1.9.0 (from 1.7.3) and Kotlin 2.2.21 (from 2.2.0), resolving deprecation warnings and ensuring compatibility with the latest stable releases.

Changes

Version Updates

  • kotlinx-serialization: 1.7.3 → 1.9.0
  • Kotlin: 2.2.0 → 2.2.21

Migration from kotlinx.datetime.Instant to kotlin.time.Instant

With Kotlin 2.2+ and kotlinx-serialization 1.9.0+, the Instant class has been moved from the kotlinx-datetime library to Kotlin's standard library (kotlin.time). This PR updates all usages:

Updated files:

  • ktoml-core/src/commonMain/kotlin/com/akuleshov7/ktoml/decoders/TomlAbstractDecoder.kt
  • ktoml-core/src/commonMain/kotlin/com/akuleshov7/ktoml/encoders/TomlAbstractEncoder.kt
  • ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/decoders/primitives/DateTimeDecoderTest.kt
  • ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/encoders/TomlDocsEncoderTest.kt

Required Opt-In Annotations

Added @OptIn(kotlin.time.ExperimentalTime::class) annotations to handle the experimental status of kotlin.time.Instant serialization support.

Developer Experience Improvement

Added a convenience test task that aliases allTests, making it easier to run all tests:

./gradlew test

Testing

All tests passing: 211 tasks (157 executed, 54 up-to-date)

  • JVM tests: ✅ Pass
  • JS/Node tests: ✅ Pass
  • Native tests (macOS, Linux, iOS): ✅ Pass
  • WASM tests: ✅ Pass

No deprecation warnings for kotlinx.datetime.Instant

Verified compatibility across all supported platforms

Background

The main breaking change in kotlinx-serialization 1.9.0 is that serialization support for Instant now uses kotlin.time.Instant from the standard library rather than kotlinx.datetime.Instant. This aligns with Kotlin 2.2's inclusion of time APIs in the standard library.

Checklist

  • All tests pass
  • No deprecation warnings introduced
  • Backward compatible (no API changes)
  • Updated all affected files
  • Verified multi-platform compatibility

🤖 Generated with Claude Code

Comment thread build.gradle.kts Outdated
allprojects {
repositories {
mavenCentral()
maven {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

hm, is this related to a Maven Central update?

I still think that mavenCentral() should work, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I couldn't get MavenCentral to work. Afaict, Kotlin 2.2.x artifacts are available on repo1.maven.org but haven't been synced yet to repo.maven.apache.org (to which Gradle's mavenCentral() resolves). You can verify this yourself:

# Returns 404
curl -sI "https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/2.2.0/kotlin-stdlib-2.2.0.pom"

# Returns 200
curl -sI "https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/2.2.0/kotlin-stdlib-2.2.0.pom"

I added comments in all the affected files noting that this can be reverted to mavenCentral() once the sync is complete. I also added settings.gradle.kts files for buildSrc/ and gradle/plugins/ with pluginManagement repository configuration, which is needed for the kotlin-dsl plugin to resolve its dependencies during the bootstrap phase.

@orchestr7
Copy link
Copy Markdown
Owner

And looks like you need to actualize and update kotlinStoreYarnLock

Updates:
- Upgrade Kotlin from 2.2.0 to 2.2.21
- Use repo1.maven.org instead of mavenCentral() for Kotlin 2.2.x artifacts
  (Kotlin 2.2.x is not yet synced to repo.maven.apache.org)
- Add settings.gradle.kts files with pluginManagement repositories
- Add convenience 'test' task alias for 'allTests'

The repository configuration change is needed because Kotlin 2.2.x artifacts
are available on repo1.maven.org but not yet synced to repo.maven.apache.org
(which Gradle's mavenCentral() uses). Once synced, these can be replaced with
mavenCentral().

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rjwalters rjwalters force-pushed the upgrade/kotlinx-serialization-1.9.0 branch from ba1966c to 8803c4a Compare December 10, 2025 06:23
@rjwalters
Copy link
Copy Markdown
Contributor Author

And looks like you need to actualize and update kotlinStoreYarnLock

Done! Ran kotlinUpgradeYarnLock and the lock file is now in sync. The branch has been rebased on the latest main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants