Skip to content

Cap Java version at 24 for Kotlin <2.3 in UpgradeToJava25#1035

Merged
timtebeek merged 5 commits intomainfrom
tim/fix-issue-2126
Mar 31, 2026
Merged

Cap Java version at 24 for Kotlin <2.3 in UpgradeToJava25#1035
timtebeek merged 5 commits intomainfrom
tim/fix-issue-2126

Conversation

@timtebeek
Copy link
Copy Markdown
Member

@timtebeek timtebeek commented Mar 31, 2026

Summary

  • Cap Java version at 24 when a project uses Kotlin <2.3 (which doesn't support Java 25)

  • Replace the single UpgradeJavaVersion(25) call with two preconditioned recipes:

    • UpgradeBuildToJava24 — applies when kotlin-stdlib <2.3 is present
    • UpgradeBuildToJava25 — applies otherwise (no Kotlin, or Kotlin >=2.3) via ModuleHasDependency with invertMarking: true
  • Pure YAML solution, no custom Java code needed

  • Fixes https://github.com/moderneinc/customer-requests/issues/2126

Test plan

  • Kotlin <2.3 project gets Java 24
  • Kotlin >=2.3 project gets Java 25
  • Project without Kotlin gets Java 25
  • Existing tests (plugin upgrades, Gradle wrapper, Lombok annotation processor) still pass

Kotlin versions before 2.3 only support up to Java 24. When running
UpgradeToJava25 on projects with kotlin-stdlib <2.3, the Java version
is now set to 24 instead of 25.
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Mar 31, 2026
@timtebeek timtebeek marked this pull request as draft March 31, 2026 10:24
Replace HasNoOldKotlinDependency with ModuleHasDependency's invertMarking
option for detecting projects without Kotlin <2.3.
Remove the intermediate UpgradeBuildToJava25 wrapper and reference
UpgradeBuildToJava24ForOldKotlin and UpgradeBuildToJava25Default
directly from UpgradeToJava25.
@timtebeek timtebeek marked this pull request as ready for review March 31, 2026 10:49
@timtebeek timtebeek merged commit 926ea39 into main Mar 31, 2026
1 check passed
@timtebeek timtebeek deleted the tim/fix-issue-2126 branch March 31, 2026 11:01
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant