Skip to content

Bump Kotlin 2.0-2.2 to 2.3 so Kotlin modules can reach Java 25#1139

Merged
timtebeek merged 6 commits into
mainfrom
tim/bump-kotlin-versions
Jun 22, 2026
Merged

Bump Kotlin 2.0-2.2 to 2.3 so Kotlin modules can reach Java 25#1139
timtebeek merged 6 commits into
mainfrom
tim/bump-kotlin-versions

Conversation

@timtebeek

@timtebeek timtebeek commented Jun 22, 2026

Copy link
Copy Markdown
Member

What

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:

  • Kotlin 2.0–2.2 → 2.3: same major version, already on the K2 compiler (default since 2.0). Minor bumps are source-compatible (with normal deprecation cycles), so this is safe to apply automatically.
  • Kotlin 1.x: left untouched. Crossing the K2 compiler default introduced in 2.0 is a real source-breaking change, so these modules stay capped at Java 24 (and keep the Explain why Kotlin modules are capped at Java 24 during Java 25 migration #1137 comment).

The existing UpgradeBuildToJava24 cap ([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

UpgradeKotlinForJava25 is wired into UpgradeToJava25 ahead of the cap. Behind the same Kotlin preconditions (ModuleHasKotlinSource + ModuleHasDependency kotlin-stdlib* [2.0,2.3)) it:

  • upgrades all org.jetbrains.kotlin dependencies to 2.3.x (covers kotlin-stdlib, kotlin-reflect, kotlin-test, … and the kotlin.version property),
  • upgrades the kotlin-maven-plugin, and
  • upgrades the Gradle org.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.csv regenerated via recipeCsvGenerate.

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jun 22, 2026
@timtebeek timtebeek marked this pull request as draft June 22, 2026 11:43
# 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.
@timtebeek timtebeek marked this pull request as ready for review June 22, 2026 12:32
@timtebeek timtebeek merged commit f3227f7 into main Jun 22, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Jun 22, 2026
@timtebeek timtebeek deleted the tim/bump-kotlin-versions branch June 22, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant