@@ -28,7 +28,8 @@ preconditions:
2828 - org.openrewrite.Singleton
2929recipeList :
3030 - org.openrewrite.java.migrate.UpgradeToJava21
31- - org.openrewrite.java.migrate.UpgradeBuildToJava24
31+ - org.openrewrite.java.migrate.UpgradeKotlinForJava25
32+ - org.openrewrite.java.migrate.UpgradeBuildToJava24ForKotlin1x
3233 - org.openrewrite.java.migrate.UpgradeBuildToJava25
3334 - org.openrewrite.java.migrate.UpgradeBuildToJava25ForKotlin
3435 - org.openrewrite.java.migrate.UpgradePluginsForJava25
@@ -43,6 +44,9 @@ recipeList:
4344 - org.openrewrite.java.migrate.SystemGetSecurityManagerToNull
4445 - org.openrewrite.java.migrate.MigrateZipErrorToZipException
4546 - org.openrewrite.java.migrate.MigrateGraalVMResourceConfig
47+ # Run last, once every module has reached its final Java version: comment the Kotlin modules that truly stayed at
48+ # Java 24 (a Kotlin 1.x cap, or a 2.0-2.2 module whose Kotlin upgrade could not be applied).
49+ - org.openrewrite.java.migrate.CommentKotlinModulesCappedAtJava24
4650
4751---
4852type : specs.openrewrite.org/v1beta/recipe
@@ -229,20 +233,77 @@ recipeList:
229233
230234---
231235type : specs.openrewrite.org/v1beta/recipe
232- name : org.openrewrite.java.migrate.UpgradeBuildToJava24
233- displayName : Upgrade build to Java 24 for Kotlin pre-2.3
236+ name : org.openrewrite.java.migrate.UpgradeKotlinForJava25
237+ displayName : Upgrade Kotlin to 2.3 for Java 25 compatibility
234238description : >-
235- Kotlin versions before 2.3 only support up to Java 24. Applies only to modules that actually compile Kotlin
239+ Only Kotlin 2.3 and later can target Java 25 bytecode, so modules on an older Kotlin are otherwise capped at Java 24.
240+ This recipe upgrades modules that compile Kotlin (i.e. contain `.kt` source files) and are already on Kotlin 2.0, 2.1,
241+ or 2.2 up to the latest Kotlin 2.3, so they can subsequently be migrated to Java 25. Modules on Kotlin 1.x are left
242+ untouched, as crossing the K2 compiler default introduced in Kotlin 2.0 is a source-breaking change that should not be
243+ applied automatically. As a safety net the module is also floored at Java 24: if the Kotlin upgrade cannot be applied
244+ (for instance because the version is managed externally by a parent or BOM), the module still lands on Java 24 rather
245+ than being left behind, and is raised the rest of the way to Java 25 only once it actually reaches Kotlin 2.3.
246+ tags :
247+ - java25
248+ - kotlin
249+ preconditions :
250+ - org.openrewrite.java.migrate.search.ModuleHasKotlinSource
251+ - org.openrewrite.java.dependencies.search.ModuleHasDependency :
252+ groupIdPattern : org.jetbrains.kotlin
253+ artifactIdPattern : kotlin-stdlib*
254+ version : " [2.0,2.3)"
255+ recipeList :
256+ - org.openrewrite.java.dependencies.UpgradeDependencyVersion :
257+ groupId : org.jetbrains.kotlin
258+ artifactId : " *"
259+ newVersion : 2.3.x
260+ - org.openrewrite.maven.UpgradePluginVersion :
261+ groupId : org.jetbrains.kotlin
262+ artifactId : kotlin-maven-plugin
263+ newVersion : 2.3.x
264+ - org.openrewrite.gradle.plugins.UpgradePluginVersion :
265+ pluginIdPattern : org.jetbrains.kotlin.*
266+ newVersion : 2.3.x
267+ # Safety-net floor: if the Kotlin bump above could not be applied (e.g. the version is managed by a parent or BOM),
268+ # the module still lands on Java 24 rather than being left behind; it reaches Java 25 only once it is on Kotlin 2.3.
269+ - org.openrewrite.java.migrate.UpgradeJavaVersion :
270+ version : 24
271+
272+ ---
273+ type : specs.openrewrite.org/v1beta/recipe
274+ name : org.openrewrite.java.migrate.UpgradeBuildToJava24ForKotlin1x
275+ displayName : Upgrade build to Java 24 for Kotlin 1.x
276+ description : >-
277+ Kotlin versions before 2.3 only support up to Java 24, and Kotlin 1.x cannot be safely upgraded automatically because
278+ crossing the K2 compiler default introduced in Kotlin 2.0 is a source-breaking change. Such modules are therefore
279+ capped at Java 24 and annotated with an explanation. Modules already on Kotlin 2.0-2.2 are instead bumped to Kotlin 2.3
280+ by `UpgradeKotlinForJava25` so they can reach Java 25. Applies only to modules that actually compile Kotlin
236281 (i.e. contain `.kt` source files), so transitive `kotlin-stdlib` dependencies do not trigger the cap.
237282preconditions :
238283 - org.openrewrite.java.migrate.search.ModuleHasKotlinSource
239284 - org.openrewrite.java.dependencies.search.ModuleHasDependency :
240285 groupIdPattern : org.jetbrains.kotlin
241286 artifactIdPattern : kotlin-stdlib*
242- version : " [0,2.3 )"
287+ version : " [0,2.0 )"
243288recipeList :
244289 - org.openrewrite.java.migrate.UpgradeJavaVersion :
245290 version : 24
291+
292+ ---
293+ type : specs.openrewrite.org/v1beta/recipe
294+ name : org.openrewrite.java.migrate.CommentKotlinModulesCappedAtJava24
295+ displayName : Comment Kotlin modules capped at Java 24
296+ description : >-
297+ Adds an explanatory comment to Kotlin modules that remain at Java 24 after the Java 25 migration, because Kotlin before
298+ 2.3 cannot target Java 25 bytecode. This covers both a Kotlin 1.x cap (which cannot be upgraded automatically) and a
299+ Kotlin 2.0-2.2 module whose upgrade to 2.3 could not be applied. Scoped to modules that actually compile Kotlin
300+ (i.e. contain `.kt` source files); the comment is self-healing, so a module that does reach Java 25 has it removed.
301+ tags :
302+ - java25
303+ - kotlin
304+ preconditions :
305+ - org.openrewrite.java.migrate.search.ModuleHasKotlinSource
306+ recipeList :
246307 - org.openrewrite.java.migrate.CommentJava24KotlinCap
247308
248309---
0 commit comments