Bump Kotlin 2.0-2.2 to 2.3 so Kotlin modules can reach Java 25#1139
Merged
Conversation
# Conflicts: # src/main/resources/META-INF/rewrite/recipes.csv # src/test/java/org/openrewrite/java/migrate/UpgradeToJava25Test.java
Make CommentJava24KotlinCap self-healing (add at Java 24, remove once the module reaches a higher version) and run it last via a new CommentKotlinModulesCappedAtJava24 wrapper scoped to Kotlin modules, so the explanation lands on every Kotlin module that truly stays at Java 24 without leaving a stale comment on modules that reach Java 25.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
kotlin-stdlibolder than 2.3 are capped at Java 24, because only Kotlin 2.3+ can target Java 25 bytecode (Explain why Kotlin modules are capped at Java 24 during Java 25 migration #1137 added an explanatory comment for those capped modules).This adds
UpgradeKotlinForJava25, which bumps modules that are already on Kotlin 2.0, 2.1, or 2.2 up to the latest Kotlin 2.3 before the Java-version step runs, so those modules reach Java 25 instead of stalling at 24.Why this is safe
The bump is scoped to the
[2.0,2.3)band only:The existing
UpgradeBuildToJava24cap ([0,2.3)) is kept as-is and acts as a safety net: any module whose Kotlin version could not be bumped stays at Java 24 rather than being wrongly raised to 25.How
UpgradeKotlinForJava25is wired intoUpgradeToJava25ahead of the cap. Behind the same Kotlin preconditions (ModuleHasKotlinSource+ModuleHasDependency kotlin-stdlib* [2.0,2.3)) it:org.jetbrains.kotlindependencies to2.3.x(coverskotlin-stdlib,kotlin-reflect,kotlin-test, … and thekotlin.versionproperty),kotlin-maven-plugin, andorg.jetbrains.kotlin.*plugins.The bump lands in the first cycle; the Java 25 upgrade applies in the next once the module is on 2.3.
Tests
UpgradeToJava25Test:kotlin2xUpgradedToLatest2_3AndJava25— a 2.2.0 module is bumped to 2.3.x and reaches Java 25.kotlin1xCapsJavaVersionAt24WithoutBumpingKotlin— a 1.9.24 module is left on Kotlin 1.x and capped at Java 24.recipes.csvregenerated viarecipeCsvGenerate.