Upgrade kotlinx-datetime to 0.7.1 and migrate Clock API#1132
Upgrade kotlinx-datetime to 0.7.1 and migrate Clock API#1132saa-chin wants to merge 6 commits intoJetBrains:developfrom
Conversation
|
Hi, I also started working on this by accident since no one had expressed intention to pick it up in any of the related issues. Updating to And then when the std-lib teams makes it stable simply remove that part. You can find the full proposed code changes here Also left some comments on the issue I would say, merge this PR for a quick fix and then investigate if you are willing to go for the full migration. |
@mltheuser this was my initial commit: 3009269?notification_referrer_id=NT_kwDOAFAXS7MyMDQ3NDgyOTE4MDo1MjQ4ODQz do you prefer that I revert to that? I changed it based on @kpavlov 's comment. |
|
Oh my bad, didn't expand the resolved review. Thats alright then. |
|
Let's rebase and update examples (markdown files) to make knit happy |
|
Hey @saa-chin @mltheuser, just wanted to ask if any of you plan to further work on this to complete the migration, or we can pick this up and finalize it ourselves? Did you hit any blocks? |
- Update kotlinx-datetime dependency from 0.6.2 to 0.7.1 in gradle/libs.versions.toml and examples - Replace all 'kotlinx.datetime.Clock' imports with 'kotlin.time.Clock' imports - The Clock.System API remains the same, just moved to kotlin.time package This resolves the NoClassDefFoundError for kotlinx/datetime/Clock$System that occurred when upgrading to kotlinx-datetime 0.7.x, where Clock was moved from kotlinx-datetime to kotlin.time package as part of the breaking changes in 0.7.0. Fixes JetBrains#1129
…lity - Updates kotlinx-datetime from 0.6.2 to 0.7.1-0.6.x-compat - Provides compatibility with existing kotlinx.datetime.Clock usage - Eliminates NoClassDefFoundError while maintaining backward compatibility - Allows gradual migration with deprecation warnings instead of breaking changes - Updated both main project and examples dependencies Closes JetBrains#1129
- Update kotlinx.datetime.Clock to kotlin.time.Clock for consistency - Ensures all files use the new Clock API consistently
060ef37 to
b788616
Compare
|
@EugeneTheDev - I have rebased, go ahead with the merge. |
|
Hey @saa-chin, I still see some errors on CI. Since you enabled "Maintainers are allowed to edit this pull request", do you mind me jumping in and fixing your PR, so that we can finally merge it? |
Motivation and Context
This PR resolves issue #1129 where users encounter java.lang.NoClassDefFoundError: kotlinx/datetime/Clock$System when trying to upgrade to kotlinx-datetime 0.7.x.
Problem: kotlinx-datetime 0.7.0 introduced breaking changes moving Clock from kotlinx.datetime to kotlin.time package, causing runtime failures for users upgrading kotlinx-datetime.
Solution: Migrates Koog to kotlinx-datetime 0.7.1-0.6.x-compat - eliminates NoClassDefFoundError while maintaining full backward compatibility with existing kotlinx.datetime.Clock usage.
Breaking Changes: None. Existing code continues working unchanged, with deprecation warnings guiding gradual migration to kotlin.time.Clock when ready.
Closes #1129
Type of the changes
Checklist
developas the base branchAdditional steps for pull requests adding a new feature
Testing Note: This change maintains the same Clock.System API surface, so existing tests that use Clock.System continue to validate the functionality. The change is purely an import migration that preserves all behavioral contracts.
For Issue Reporter (@IanArb): This PR should resolve your
NoClassDefFoundErrorand eliminate the need for the temporary workaround mentioned by @EurigJones. After this is merged, you'll be able to use kotlinx-datetime 0.7.x with Koog without any dependency resolution strategies.