From 81d85c3cd1a796951a35704af3aa65f04d3086df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Merlin=20B=C3=B6gershausen?= Date: Fri, 29 May 2026 12:38:01 +0200 Subject: [PATCH 1/2] Align Kotlin jvmTarget with the Java version during UpgradeJavaVersion When UpgradeJavaVersion bumps a project's Java version, the Kotlin compiler keeps emitting bytecode at the older jvmTarget, leaving Kotlin classes at a mismatched bytecode level. UpgradeJavaVersion now also runs a new UpgradeKotlinJvmTargetVersion recipe that raises the Kotlin jvmTarget to match the requested Java version across: - kotlin-maven-plugin configuration - Gradle Groovy and Kotlin DSL kotlinOptions/compilerOptions blocks (string and JvmTarget.JVM_X forms, including the jvmTarget.set(...) provider) It never downgrades, and is a no-op for non-Kotlin projects. This flows through the existing UpgradeBuildToJava*ForKotlin recipes, which delegate to UpgradeJavaVersion. Discovered while testing the Spring Boot 4 migration for Kotlin. See moderneinc/customer-requests#2439 --- build.gradle.kts | 2 +- .../java/migrate/UpgradeJavaVersion.java | 3 +- .../UpgradeKotlinJvmTargetVersion.java | 274 ++++++++++++++++ .../resources/META-INF/rewrite/recipes.csv | 27 +- .../UpgradeKotlinJvmTargetVersionTest.java | 305 ++++++++++++++++++ 5 files changed, 596 insertions(+), 15 deletions(-) create mode 100644 src/main/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersion.java create mode 100644 src/test/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersionTest.java diff --git a/build.gradle.kts b/build.gradle.kts index 47abf36f03..024810922e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -56,6 +56,7 @@ dependencies { implementation(platform("org.openrewrite:rewrite-bom:${rewriteVersion}")) implementation("org.openrewrite:rewrite-java") + implementation("org.openrewrite:rewrite-kotlin") implementation("org.openrewrite:rewrite-properties") implementation("org.openrewrite:rewrite-xml") implementation("org.openrewrite:rewrite-json") @@ -80,7 +81,6 @@ dependencies { testImplementation("org.junit-pioneer:junit-pioneer:2.0.0") testImplementation("org.openrewrite:rewrite-test") - testImplementation("org.openrewrite:rewrite-kotlin") testImplementation("org.openrewrite.gradle.tooling:model:$rewriteVersion") testImplementation("org.assertj:assertj-core:latest.release") diff --git a/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java b/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java index 8b81ca76a7..b741969734 100644 --- a/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java +++ b/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java @@ -55,7 +55,8 @@ public List getRecipeList() { new org.openrewrite.jenkins.UpgradeJavaVersion(version, null), new UpdateJavaCompatibility(version, null, null, false, null), new UpdateSdkMan(String.valueOf(version), null), - new UpgradeDockerImageVersion(version) + new UpgradeDockerImageVersion(version), + new UpgradeKotlinJvmTargetVersion(version) ); } diff --git a/src/main/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersion.java b/src/main/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersion.java new file mode 100644 index 0000000000..bd714a8bc1 --- /dev/null +++ b/src/main/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersion.java @@ -0,0 +1,274 @@ +/* + * Copyright 2026 the original author or authors. + *

+ * Licensed under the Moderne Source Available License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://docs.moderne.io/licensing/moderne-source-available-license + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.java.migrate; + +import lombok.EqualsAndHashCode; +import lombok.Value; +import org.jspecify.annotations.Nullable; +import org.openrewrite.Cursor; +import org.openrewrite.ExecutionContext; +import org.openrewrite.Option; +import org.openrewrite.Recipe; +import org.openrewrite.SourceFile; +import org.openrewrite.Tree; +import org.openrewrite.TreeVisitor; +import org.openrewrite.groovy.GroovyIsoVisitor; +import org.openrewrite.java.MethodMatcher; +import org.openrewrite.java.tree.Expression; +import org.openrewrite.java.tree.J; +import org.openrewrite.kotlin.KotlinIsoVisitor; +import org.openrewrite.maven.MavenIsoVisitor; +import org.openrewrite.xml.ChangeTagValueVisitor; +import org.openrewrite.xml.tree.Xml; + +import java.util.Collections; +import java.util.Iterator; + +@EqualsAndHashCode(callSuper = false) +@Value +public class UpgradeKotlinJvmTargetVersion extends Recipe { + + // Gradle build scripts usually lack type attribution, so match by name + arity (matchUnknownTypes=true at call sites). + private static final MethodMatcher KOTLIN_OPTIONS = new MethodMatcher("* kotlinOptions(..)"); + private static final MethodMatcher COMPILER_OPTIONS = new MethodMatcher("* compilerOptions(..)"); + private static final MethodMatcher JVM_TARGET_SET = new MethodMatcher("* set(..)"); + + @Option(displayName = "Java version", + description = "The Java version to align Kotlin's `jvmTarget` with.", + example = "21") + Integer version; + + String displayName = "Upgrade Kotlin `jvmTarget` to match the Java version"; + + String description = "Align the Kotlin `jvmTarget` with the project's Java version so the Kotlin compiler emits " + + "bytecode at the same level as `javac`. Covers `kotlin-maven-plugin` `` configuration and the " + + "Gradle `kotlinOptions { jvmTarget = ... }` / `compilerOptions { jvmTarget = ... }` blocks (Groovy and " + + "Kotlin DSL). Will not downgrade if the existing Kotlin target is higher than the requested version."; + + @Override + public TreeVisitor getVisitor() { + String newVersion = version.toString(); + int target = version; + // Each language visitor already accepts only its own source kind (the Maven visitor even narrows to actual + // Maven poms), so route on `isAcceptable` rather than re-checking compilation-unit types here. + TreeVisitor maven = mavenVisitor(target); + TreeVisitor groovy = gradleGroovyVisitor(newVersion, target); + TreeVisitor kotlin = gradleKotlinDslVisitor(newVersion, target); + return new TreeVisitor() { + @Override + public @Nullable Tree visit(@Nullable Tree tree, ExecutionContext ctx) { + if (tree instanceof SourceFile) { + SourceFile sourceFile = (SourceFile) tree; + if (maven.isAcceptable(sourceFile, ctx)) { + return maven.visit(tree, ctx); + } + if (groovy.isAcceptable(sourceFile, ctx)) { + return groovy.visit(tree, ctx); + } + if (kotlin.isAcceptable(sourceFile, ctx)) { + return kotlin.visit(tree, ctx); + } + } + return tree; + } + }; + } + + private static MavenIsoVisitor mavenVisitor(int target) { + return new MavenIsoVisitor() { + @Override + public Xml.Tag visitTag(Xml.Tag tag, ExecutionContext ctx) { + Xml.Tag t = super.visitTag(tag, ctx); + if (!isPluginTag("org.jetbrains.kotlin", "kotlin-maven-plugin")) { + return t; + } + Xml.Tag jvmTarget = t.getChild("configuration") + .flatMap(config -> config.getChild("jvmTarget")) + .orElse(null); + if (jvmTarget == null) { + return t; + } + Integer current = parseJvmTarget(jvmTarget.getValue().orElse(null)); + if (current == null || current >= target) { + return t; + } + return (Xml.Tag) new ChangeTagValueVisitor<>(jvmTarget, Integer.toString(target)).visitNonNull(t, ctx); + } + }; + } + + private static GroovyIsoVisitor gradleGroovyVisitor(String newVersion, int target) { + return new GroovyIsoVisitor() { + @Override + public J.Assignment visitAssignment(J.Assignment assignment, ExecutionContext ctx) { + J.Assignment a = super.visitAssignment(assignment, ctx); + if (!isInsideKotlinCompilerBlock(getCursor())) { + return a; + } + Expression variable = a.getVariable(); + if (!(variable instanceof J.Identifier) + || !"jvmTarget".equals(((J.Identifier) variable).getSimpleName())) { + return a; + } + Expression rhs = a.getAssignment(); + if (!(rhs instanceof J.Literal)) { + return a; + } + J.Literal literal = (J.Literal) rhs; + Object value = literal.getValue(); + if (!(value instanceof String)) { + return a; + } + Integer current = parseJvmTarget((String) value); + if (current == null || current >= target) { + return a; + } + // Preserve the original quote style (Groovy allows both ' and "). + String original = literal.getValueSource(); + char quote = original != null && !original.isEmpty() ? original.charAt(0) : '\''; + return a.withAssignment(literal + .withValue(newVersion) + .withValueSource(quote + newVersion + quote)); + } + }; + } + + private static KotlinIsoVisitor gradleKotlinDslVisitor(String newVersion, int target) { + return new KotlinIsoVisitor() { + @Override + public J.Assignment visitAssignment(J.Assignment assignment, ExecutionContext ctx) { + J.Assignment a = super.visitAssignment(assignment, ctx); + if (!isInsideKotlinCompilerBlock(getCursor())) { + return a; + } + Expression variable = a.getVariable(); + if (!(variable instanceof J.Identifier) + || !"jvmTarget".equals(((J.Identifier) variable).getSimpleName())) { + return a; + } + Expression rhs = a.getAssignment(); + if (rhs instanceof J.Literal) { + return bumpLiteralAssignment(a, (J.Literal) rhs, newVersion, target); + } + if (rhs instanceof J.FieldAccess) { + J.FieldAccess fa = (J.FieldAccess) rhs; + J.FieldAccess bumped = bumpedJvmTargetFieldAccess(fa, newVersion, target); + return bumped == fa ? a : a.withAssignment(bumped); + } + return a; + } + + @Override + public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { + J.MethodInvocation mi = super.visitMethodInvocation(method, ctx); + // Match the Provider-style setter `jvmTarget.set(JvmTarget.JVM_X)`. + if (!JVM_TARGET_SET.matches(mi, true) || !(mi.getSelect() instanceof J.Identifier)) { + return mi; + } + if (!"jvmTarget".equals(((J.Identifier) mi.getSelect()).getSimpleName())) { + return mi; + } + if (!isInsideKotlinCompilerBlock(getCursor())) { + return mi; + } + if (mi.getArguments().size() != 1) { + return mi; + } + Expression arg = mi.getArguments().get(0); + if (arg instanceof J.FieldAccess) { + J.FieldAccess fa = (J.FieldAccess) arg; + J.FieldAccess bumped = bumpedJvmTargetFieldAccess(fa, newVersion, target); + if (bumped != fa) { + return mi.withArguments(Collections.singletonList(bumped)); + } + } + return mi; + } + }; + } + + // Gradle build scripts lack type attribution, so there is no trait that models "inside the compilerOptions + // block" — walk the cursor ancestry and match the enclosing DSL block by name (matchUnknownTypes=true), the + // same approach `org.openrewrite.gradle.UpdateJavaCompatibility` uses for `java { }` / `sourceCompatibility`. + private static boolean isInsideKotlinCompilerBlock(Cursor cursor) { + Iterator path = cursor.getPath(); + while (path.hasNext()) { + Object o = path.next(); + if (o instanceof J.MethodInvocation) { + J.MethodInvocation mi = (J.MethodInvocation) o; + if (KOTLIN_OPTIONS.matches(mi, true) || COMPILER_OPTIONS.matches(mi, true)) { + return true; + } + } + } + return false; + } + + private static J.Assignment bumpLiteralAssignment(J.Assignment a, J.Literal literal, String newVersion, int target) { + Object value = literal.getValue(); + if (!(value instanceof String)) { + return a; + } + Integer current = parseJvmTarget((String) value); + if (current == null || current >= target) { + return a; + } + return a.withAssignment(literal + .withValue(newVersion) + .withValueSource("\"" + newVersion + "\"")); + } + + /** + * If the FieldAccess is a {@code JvmTarget.JVM_X} reference with X less than {@code target}, + * return a new FieldAccess with the bumped enum name. Returns the original instance unchanged otherwise. + */ + private static J.FieldAccess bumpedJvmTargetFieldAccess(J.FieldAccess fa, String newVersion, int target) { + if (!(fa.getTarget() instanceof J.Identifier) + || !"JvmTarget".equals(((J.Identifier) fa.getTarget()).getSimpleName())) { + return fa; + } + String enumName = fa.getSimpleName(); + if (!enumName.startsWith("JVM_")) { + return fa; + } + // Enum constants spell the version with underscores ("JVM_1_8", "JVM_11"); normalize to the dotted/plain + // form parseJvmTarget understands ("1.8", "11"). + Integer current = parseJvmTarget(enumName.substring("JVM_".length()).replace('_', '.')); + if (current == null || current >= target) { + return fa; + } + return fa.withName(fa.getName().withSimpleName("JVM_" + newVersion)); + } + + /** + * Parse a Kotlin {@code jvmTarget} string ("1.8", "11", "21") to the corresponding major Java version. + * Returns {@code null} if the value cannot be parsed (do-no-harm). + */ + private static @Nullable Integer parseJvmTarget(@Nullable String raw) { + if (raw == null) { + return null; + } + String trimmed = raw.trim(); + if ("1.8".equals(trimmed)) { + return 8; + } + try { + return Integer.parseInt(trimmed); + } catch (NumberFormatException e) { + return null; + } + } +} diff --git a/src/main/resources/META-INF/rewrite/recipes.csv b/src/main/resources/META-INF/rewrite/recipes.csv index a86747a70d..e97c38f734 100644 --- a/src/main/resources/META-INF/rewrite/recipes.csv +++ b/src/main/resources/META-INF/rewrite/recipes.csv @@ -12,7 +12,7 @@ maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.R maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UseTabsOrSpaces,Force indentation to either tabs or spaces,"This is useful for one-off migrations of a codebase that has mixed indentation styles, while preserving all other auto-detected formatting rules.",1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,"[{""name"":""useTabs"",""type"":""boolean"",""displayName"":""Use tabs"",""description"":""Whether to use tabs for indentation."",""required"":true,""value"":false}]", maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.BeanDiscovery,Behavior change to bean discovery in modules with `beans.xml` file with no version specified,Alters beans with missing version attribute to include this attribute as well as the bean-discovery-mode="all" attribute to maintain an explicit bean archive.,1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.MXBeanRule,MBean and MXBean interfaces must be public,Sets visibility of MBean and MXBean interfaces to public.,1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeJavaVersion,Upgrade Java version,"Upgrade build plugin configuration to use the specified Java version. This recipe changes `java.toolchain.languageVersion` in `build.gradle(.kts)` of gradle projects, or maven-compiler-plugin target version and related settings. Will not downgrade if the version is newer than the specified version.",7,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,"[{""name"":""version"",""type"":""Integer"",""displayName"":""Java version"",""description"":""The Java version to upgrade to."",""example"":""11"",""required"":true}]", +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeJavaVersion,Upgrade Java version,"Upgrade build plugin configuration to use the specified Java version. This recipe changes `java.toolchain.languageVersion` in `build.gradle(.kts)` of gradle projects, or maven-compiler-plugin target version and related settings. Will not downgrade if the version is newer than the specified version.",8,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,"[{""name"":""version"",""type"":""Integer"",""displayName"":""Java version"",""description"":""The Java version to upgrade to."",""example"":""11"",""required"":true}]", maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.AddSuppressionForIllegalReflectionWarningsPlugin,Add maven jar plugin to suppress illegal reflection warnings,Adds a maven jar plugin that's configured to suppress Illegal Reflection Warnings.,1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,"[{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""An exact version number, or node-style semver selector used to select the version number."",""example"":""29.X""}]", maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.DontOverfetchDto,Replace DTO method parameters with data elements,Replace method parameters that have DTOs with their data elements when only the specified data element is used.,1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,"[{""name"":""dtoType"",""type"":""String"",""displayName"":""DTO type"",""description"":""The fully qualified name of the DTO."",""example"":""animals.Dog"",""required"":true},{""name"":""dtoDataElement"",""type"":""String"",""displayName"":""Data element"",""description"":""Replace the DTO as a method parameter when only this data element is used."",""example"":""name"",""required"":true}]", maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpdateSdkMan,Update SDKMan Java version,"Update the SDKMAN JDK version in the `.sdkmanrc` file. Given a major release (e.g., 17), the recipe will update the current distribution to the current default SDKMAN version of the specified major release. The distribution option can be used to specify a specific JVM distribution. Note that these must correspond to valid SDKMAN distributions.",1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,"[{""name"":""newVersion"",""type"":""String"",""displayName"":""Java version"",""description"":""The Java version to update to. Use `latest.patch` to upgrade to the latest version within the current major version."",""example"":""17""},{""name"":""newDistribution"",""type"":""String"",""displayName"":""Distribution"",""description"":""The JVM distribution to use."",""example"":""tem""}]", @@ -26,6 +26,7 @@ maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.A maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.BeansXmlNamespace,Change `beans.xml` `schemaLocation` to match XML namespace,Set the `schemaLocation` that corresponds to the `xmlns` set in `beans.xml` files.,1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.MigrateGraalVMResourceConfig,Migrate GraalVM resource-config.json to glob patterns,Migrates GraalVM native-image resource-config.json files from the legacy regex pattern format (JDK 21 and earlier) to the new glob pattern format (JDK 23+). Converts `pattern` entries to `glob` entries and restructures the format. Note: `excludes` are no longer supported in the new format and will be removed.,1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.JpaCacheProperties,Disable the persistence unit second-level cache,Sets an explicit value for the shared cache mode.,1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeKotlinJvmTargetVersion,Upgrade Kotlin `jvmTarget` to match the Java version,Align the Kotlin `jvmTarget` with the project's Java version so the Kotlin compiler emits bytecode at the same level as `javac`. Covers `kotlin-maven-plugin` `` configuration and the Gradle `kotlinOptions { jvmTarget = ... }` / `compilerOptions { jvmTarget = ... }` blocks (Groovy and Kotlin DSL). Will not downgrade if the existing Kotlin target is higher than the requested version.,1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,"[{""name"":""version"",""type"":""Integer"",""displayName"":""Java version"",""description"":""The Java version to align Kotlin's `jvmTarget` with."",""example"":""21"",""required"":true}]", maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.JREThrowableFinalMethods,Rename final method declarations `getSuppressed()` and `addSuppressed(Throwable exception)` in classes that extend `Throwable`,The recipe renames `getSuppressed()` and `addSuppressed(Throwable exception)` methods in classes that extend `java.lang.Throwable` to `myGetSuppressed` and `myAddSuppressed(Throwable)`. These methods were added to Throwable in Java 7 and are marked final which cannot be overridden.,1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.ReferenceCloneMethod,Replace `java.lang.ref.Reference.clone()` with constructor call,"The recipe replaces any clone calls that may resolve to a `java.lang.ref.Reference.clone()` or any of its known subclasses: `java.lang.ref.PhantomReference`, `java.lang.ref.SoftReference`, and `java.lang.ref.WeakReference` with a constructor call passing in the referent and reference queue as parameters.",1,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.BouncyCastleFromJdk15OnToJdk15to18,Migrate Bouncy Castle from `jdk15on` to `jdk15to18` for Java < 8,This recipe replaces the Bouncy Castle artifacts from `jdk15on` to `jdk15to18`. `jdk15on` isn't maintained anymore and `jdk18on` is only for Java 8 and above. The `jdk15to18` artifact is the up-to-date replacement of the unmaintained `jdk15on` for Java < 8.,8,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, @@ -41,18 +42,18 @@ maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.R maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.RemovedJaxBModuleProvided,Do not package `java.xml.bind` and `java.activation` modules in WebSphere Liberty applications,"The `java.xml.bind` and `java.activation` modules were removed in Java11. Websphere Liberty provides its own implementation of the modules, which can be used by specifying the `jaxb-2.2` feature in the server.xml file. This recipe updates the `javax.xml.bind` and `javax.activation` dependencies to use the `provided` scope to avoid class loading issues.",5,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.WasDevMvnChangeParentArtifactId,Change `net.wasdev.maven.parent:java8-parent` to `:parent`,This recipe changes the artifactId of the `` tag in the `pom.xml` from `java8-parent` to `parent`.,2,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.ComIntelliJAnnotationsToOrgJetbrainsAnnotations,Migrate com.intellij:annotations to org.jetbrains:annotations,This recipe will upgrade old dependency of com.intellij:annotations to the newer org.jetbrains:annotations.,2,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.JavaBestPractices,Java best practices,"Applies opinionated best practices for Java projects targeting Java 25. This recipe includes the full Java 25 upgrade chain plus additional improvements to code style, API usage, and third-party dependency reduction that go beyond what the version migration recipes apply.",1498,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.JavaBestPractices,Java best practices,"Applies opinionated best practices for Java projects targeting Java 25. This recipe includes the full Java 25 upgrade chain plus additional improvements to code style, API usage, and third-party dependency reduction that go beyond what the version migration recipes apply.",1505,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.javaee6,Migrate to JavaEE6,"These recipes help with the Migration to Java EE 6, flagging and updating deprecated methods.",2,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.javaee7,Migrate to JavaEE7,"These recipes help with the Migration to Java EE 7, flagging and updating deprecated methods.",8,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.javaee8,Migrate to JavaEE8,"These recipes help with the Migration to Java EE 8, flagging and updating deprecated methods.",18,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.Java8toJava11,Migrate to Java 11,"This recipe will apply changes commonly needed when upgrading to Java 11. Specifically, for those applications that are built on Java 8, this recipe will update and add dependencies on J2EE libraries that are no longer directly bundled with the JDK. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy. Build files will also be updated to use Java 11 as the target/source and plugins will be also be upgraded to versions that are compatible with Java 11.",253,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava11,Upgrade build to Java 11,Updates build files to use Java 11 as the target/source.,38,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.Java8toJava11,Migrate to Java 11,"This recipe will apply changes commonly needed when upgrading to Java 11. Specifically, for those applications that are built on Java 8, this recipe will update and add dependencies on J2EE libraries that are no longer directly bundled with the JDK. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy. Build files will also be updated to use Java 11 as the target/source and plugins will be also be upgraded to versions that are compatible with Java 11.",255,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava11,Upgrade build to Java 11,Updates build files to use Java 11 as the target/source.,39,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradePluginsForJava11,Upgrade plugins to Java 11 compatible versions,Updates plugins to version compatible with Java 11.,6,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.InternalBindPackages,Use `com.sun.xml.bind.*` instead of `com.sun.xml.internal.bind.*`,Do not use APIs from `com.sun.xml.internal.bind.*` packages.,2,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.RemovedPolicy,Replace `javax.security.auth.Policy` with `java.security.Policy`,The `javax.security.auth.Policy` class is not available from Java SE 11 onwards.,2,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.ThreadStopDestroy,Remove `Thread.destroy()` and `Thread.stop(Throwable)`,"The `java.lang.Thread.destroy()` method was never implemented, and the `java.lang.Thread.stop(java.lang.Throwable)` method has been unusable since Java SE 8. This recipe removes any usage of these methods from your application.",3,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeToJava17,Migrate to Java 17,"This recipe will apply changes commonly needed when migrating to Java 17. Specifically, for those applications that are built on Java 8, this recipe will update and add dependencies on J2EE libraries that are no longer directly bundled with the JDK. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy. Build files will also be updated to use Java 17 as the target/source and plugins will be also be upgraded to versions that are compatible with Java 17.",413,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava17,Upgrade build to Java 17,Updates build files to use Java 17 as the target/source.,98,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeToJava17,Migrate to Java 17,"This recipe will apply changes commonly needed when migrating to Java 17. Specifically, for those applications that are built on Java 8, this recipe will update and add dependencies on J2EE libraries that are no longer directly bundled with the JDK. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy. Build files will also be updated to use Java 17 as the target/source and plugins will be also be upgraded to versions that are compatible with Java 17.",416,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava17,Upgrade build to Java 17,Updates build files to use Java 17 as the target/source.,99,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradePluginsForJava17,Upgrade plugins to Java 17 compatible versions,Updates plugins to version compatible with Java 17.,8,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.DeprecatedJavaxSecurityCert,Use `java.security.cert` instead of `javax.security.cert`,The `javax.security.cert` package has been deprecated for removal.,2,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.RemovedLegacySunJSSEProviderName,Use `SunJSSE` instead of `com.sun.net.ssl.internal.ssl.Provider`,The `com.sun.net.ssl.internal.ssl.Provider` provider name was removed.,2,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, @@ -72,13 +73,13 @@ maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.R maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.RemovedRuntimeTraceMethods,Remove `Runtime.traceInstructions(boolean)` and `Runtime.traceMethodCalls` methods,The `traceInstructions` and `traceMethodCalls` methods in `java.lang.Runtime` were deprecated in Java SE 9 and are no longer available in Java SE 13 and later. The recipe removes the invocations of these methods since the method invocations do nothing functionally.,3,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.AddLombokMapstructBinding,Add `lombok-mapstruct-binding` when both MapStruct and Lombok are used,Add the `lombok-mapstruct-binding` annotation processor as needed when both MapStruct and Lombok are used.,5,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.AddLombokMapstructBindingMavenDependencyOnly,Add `lombok-mapstruct-binding` dependency for Maven when both MapStruct and Lombok are used,"Add the `lombok-mapstruct-binding` when both MapStruct and Lombok are used, and the dependency does not already exist. Only to be called from `org.openrewrite.java.migrate.AddLombokMapstructBinding` to reduce redundant checks.",2,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeToJava21,Migrate to Java 21,This recipe will apply changes commonly needed when migrating to Java 21. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy. Build files will also be updated to use Java 21 as the target/source and plugins will be also be upgraded to versions that are compatible with Java 21.,588,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava21,Upgrade build to Java 21,Updates build files to use Java 21 as the target/source.,138,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeToJava21,Migrate to Java 21,This recipe will apply changes commonly needed when migrating to Java 21. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy. Build files will also be updated to use Java 21 as the target/source and plugins will be also be upgraded to versions that are compatible with Java 21.,592,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava21,Upgrade build to Java 21,Updates build files to use Java 21 as the target/source.,139,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradePluginsForJava21,Upgrade plugins to Java 21 compatible versions,Updates plugins and dependencies to version compatible with Java 21.,6,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.RemovedSubjectMethods,Adopt `javax.security.auth.Subject.current()` and `javax.security.auth.Subject.callAs()` methods`,Replaces the `javax.security.auth.Subject.getSubject()` and `javax.security.auth.Subject.doAs()` methods with `javax.security.auth.Subject.current()` and `javax.security.auth.Subject.callAs()`.,3,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.DeleteDeprecatedFinalize,Avoid using the deprecated empty `finalize()` method in `java.desktop`,The java.desktop module had a few implementations of finalize() that did nothing and have been removed. This recipe will remove these methods.,4,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.SwitchPatternMatching,Adopt switch pattern matching (JEP 441),[JEP 441](https://openjdk.org/jeps/441) describes how some switch statements can be improved with pattern matching. This recipe applies some of those improvements where applicable.,3,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeToJava25,Migrate to Java 25,This recipe will apply changes commonly needed when migrating to Java 25. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy. Build files will also be updated to use Java 25 as the target/source and plugins will be also be upgraded to versions that are compatible with Java 25.,1149,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeToJava25,Migrate to Java 25,This recipe will apply changes commonly needed when migrating to Java 25. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy. Build files will also be updated to use Java 25 as the target/source and plugins will be also be upgraded to versions that are compatible with Java 25.,1156,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.AccessController,Remove Security AccessController,The Security Manager API is unsupported in Java 24. This recipe will remove the usage of `java.security.AccessController`.,4,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.RemoveSecurityPolicy,Remove Security Policy,The Security Manager API is unsupported in Java 24. This recipe will remove the use of `java.security.Policy`.,4,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.RemoveSecurityManager,Remove Security SecurityManager,The Security Manager API is unsupported in Java 24. This recipe will remove the usage of `java.security.SecurityManager`.,4,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, @@ -87,14 +88,14 @@ maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.M maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.EnableLombokAnnotationProcessor,Enable Lombok annotation processor,With Java 23 the encapsulation of JDK internals made it necessary to configure annotation processors like Lombok explicitly. The change is valid for older versions as well.,3,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradePluginsForJava25,Upgrade plugins to Java 25 compatible versions,Updates plugins and dependencies to versions compatible with Java 25.,10,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.AddSurefireFailsafeArgLineForMockito,Add surefire `--add-opens` for Mockito/ByteBuddy,Adds `--add-opens` JVM arguments required by Mockito and ByteBuddy to the Maven Surefire and Failsafe plugin `argLine` configuration. Only applied when the project depends on Mockito.,2,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava24,Upgrade build to Java 24 for Kotlin pre-2.3,"Kotlin versions before 2.3 only support up to Java 24. Applies only to modules that actually compile Kotlin (i.e. contain `.kt` source files), so transitive `kotlin-stdlib` dependencies do not trigger the cap.",168,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava25,Upgrade build to Java 25 (non-Kotlin),"Upgrades build files to Java 25 for modules without Kotlin source files. This covers pure Java projects, including those that only pick up `kotlin-stdlib` transitively through another dependency.",178,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava25ForKotlin,Upgrade build to Java 25 for Kotlin 2.3+,Upgrades build files to Java 25 for Kotlin modules already on Kotlin 2.3 or later.,178,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava24,Upgrade build to Java 24 for Kotlin pre-2.3,"Kotlin versions before 2.3 only support up to Java 24. Applies only to modules that actually compile Kotlin (i.e. contain `.kt` source files), so transitive `kotlin-stdlib` dependencies do not trigger the cap.",169,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava25,Upgrade build to Java 25 (non-Kotlin),"Upgrades build files to Java 25 for modules without Kotlin source files. This covers pure Java projects, including those that only pick up `kotlin-stdlib` transitively through another dependency.",179,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeBuildToJava25ForKotlin,Upgrade build to Java 25 for Kotlin 2.3+,Upgrades build files to Java 25 for Kotlin modules already on Kotlin 2.3 or later.,179,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeToJava6,Migrate to Java 6,This recipe will apply changes commonly needed when upgrading to Java 6. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy.,7,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.JREWrapperInterface,Add missing `isWrapperFor` and `unwrap` methods,Add method implementations stubs to classes that implement `java.sql.Wrapper`.,3,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeToJava7,Migrate to Java 7,This recipe will apply changes commonly needed when upgrading to Java 7. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy.,28,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.JREJdbcInterfaceNewMethods,Adds missing JDBC interface methods,Add method implementations stubs to classes that implement JDBC interfaces.,10,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, -maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeToJava8,Migrate to Java 8,This recipe will apply changes commonly needed when upgrading to Java 8. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy.,53,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.UpgradeToJava8,Migrate to Java 8,This recipe will apply changes commonly needed when upgrading to Java 8. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy.,54,,,Modernize,Java,,,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,,"[{""name"":""org.openrewrite.maven.table.MavenMetadataFailures"",""displayName"":""Maven metadata failures"",""instanceName"":""Maven metadata failures"",""description"":""Attempts to resolve maven metadata that failed."",""columns"":[{""name"":""group"",""type"":""String"",""displayName"":""Group id"",""description"":""The groupId of the artifact for which the metadata download failed.""},{""name"":""artifactId"",""type"":""String"",""displayName"":""Artifact id"",""description"":""The artifactId of the artifact for which the metadata download failed.""},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""The version of the artifact for which the metadata download failed.""},{""name"":""mavenRepositoryUri"",""type"":""String"",""displayName"":""Maven repository"",""description"":""The URL of the Maven repository that the metadata download failed on.""},{""name"":""snapshots"",""type"":""String"",""displayName"":""Snapshots"",""description"":""Does the repository support snapshots.""},{""name"":""releases"",""type"":""String"",""displayName"":""Releases"",""description"":""Does the repository support releases.""},{""name"":""failure"",""type"":""String"",""displayName"":""Failure"",""description"":""The reason the metadata download failed.""}]}]" maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.guava.NoGuavaRefasterRecipes$PreconditionsCheckNotNullWithMessageToObjectsRequireNonNullRecipe,`Preconditions.checkNotNull` with `String` message to `Objects.requireNonNull`,Migrate from Guava `Preconditions.checkNotNull` to Java 8 `java.util.Objects.requireNonNull`.,1,,Guava,Modernize,Java,,Recipes for migrating from [Google Guava](https://github.com/google/guava) to Java standard library.,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.guava.NoGuavaMapsNewLinkedHashMap,Prefer `new LinkedHashMap<>()`,Prefer the Java standard library over third-party usage of Guava in simple cases like this.,1,,Guava,Modernize,Java,,Recipes for migrating from [Google Guava](https://github.com/google/guava) to Java standard library.,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.guava.NoGuavaImmutableSetOf,Prefer `Set.of(..)` in Java 9 or higher,Replaces `.common.collect.ImmutableSet.of(..)` if the returned type is immediately down-cast.,1,,Guava,Modernize,Java,,Recipes for migrating from [Google Guava](https://github.com/google/guava) to Java standard library.,Modernize your code to best use the project's current JDK version. Take advantage of newly available APIs and reduce the dependency of your code on third party dependencies where there is equivalent functionality in the Java standard library.,Basic building blocks for transforming Java code.,, diff --git a/src/test/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersionTest.java b/src/test/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersionTest.java new file mode 100644 index 0000000000..82f11ca849 --- /dev/null +++ b/src/test/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersionTest.java @@ -0,0 +1,305 @@ +/* + * Copyright 2026 the original author or authors. + *

+ * Licensed under the Moderne Source Available License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://docs.moderne.io/licensing/moderne-source-available-license + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.java.migrate; + +import org.junit.jupiter.api.Test; +import org.openrewrite.DocumentExample; +import org.openrewrite.Issue; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; + +import static org.openrewrite.gradle.Assertions.buildGradle; +import static org.openrewrite.gradle.Assertions.buildGradleKts; +import static org.openrewrite.maven.Assertions.pomXml; + +class UpgradeKotlinJvmTargetVersionTest implements RewriteTest { + + @Override + public void defaults(RecipeSpec spec) { + spec.recipe(new UpgradeKotlinJvmTargetVersion(21)); + } + + @DocumentExample + @Issue("https://github.com/moderneinc/customer-requests/issues/2439") + @Test + void upgradesKotlinMavenPluginJvmTarget() { + rewriteRun( + pomXml( + //language=xml + """ + + 4.0.0 + org.example + demo + 1.0.0 + + + + org.jetbrains.kotlin + kotlin-maven-plugin + 1.9.24 + + 11 + + -Xjsr305=strict + + + + + + + """, + //language=xml + """ + + 4.0.0 + org.example + demo + 1.0.0 + + + + org.jetbrains.kotlin + kotlin-maven-plugin + 1.9.24 + + 21 + + -Xjsr305=strict + + + + + + + """ + ) + ); + } + + @Test + void upgradesGradleGroovyKotlinOptionsJvmTarget() { + rewriteRun( + buildGradle( + """ + plugins { + id 'org.jetbrains.kotlin.jvm' version '1.9.24' + } + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { + kotlinOptions { + jvmTarget = '11' + } + } + """, + """ + plugins { + id 'org.jetbrains.kotlin.jvm' version '1.9.24' + } + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { + kotlinOptions { + jvmTarget = '21' + } + } + """ + ) + ); + } + + @Test + void preservesGroovyDoubleQuoteStyle() { + rewriteRun( + buildGradle( + """ + plugins { + id 'org.jetbrains.kotlin.jvm' version '1.9.24' + } + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { + kotlinOptions { + jvmTarget = "11" + } + } + """, + """ + plugins { + id 'org.jetbrains.kotlin.jvm' version '1.9.24' + } + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { + kotlinOptions { + jvmTarget = "21" + } + } + """ + ) + ); + } + + @Test + void upgradesGradleKotlinDslCompilerOptionsJvmTarget() { + rewriteRun( + buildGradleKts( + """ + import org.jetbrains.kotlin.gradle.dsl.JvmTarget + + plugins { + kotlin("jvm") version "1.9.24" + } + kotlin { + compilerOptions { + jvmTarget = JvmTarget.JVM_11 + } + } + """, + """ + import org.jetbrains.kotlin.gradle.dsl.JvmTarget + + plugins { + kotlin("jvm") version "1.9.24" + } + kotlin { + compilerOptions { + jvmTarget = JvmTarget.JVM_21 + } + } + """ + ) + ); + } + + @Test + void doNotDowngradeGradleGroovy() { + rewriteRun( + buildGradle( + """ + plugins { + id 'org.jetbrains.kotlin.jvm' version '2.0.0' + } + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { + kotlinOptions { + jvmTarget = '25' + } + } + """ + ) + ); + } + + @Test + void doNotChangeGradleGroovyJvmTargetOutsideKotlinBlock() { + rewriteRun( + buildGradle( + """ + plugins { + id 'org.jetbrains.kotlin.jvm' version '1.9.24' + } + ext { + jvmTarget = '11' + } + """ + ) + ); + } + + @Test + void doNotDowngradeGradleKotlinDsl() { + rewriteRun( + buildGradleKts( + """ + import org.jetbrains.kotlin.gradle.dsl.JvmTarget + + plugins { + kotlin("jvm") version "2.0.0" + } + kotlin { + compilerOptions { + jvmTarget = JvmTarget.JVM_25 + } + } + """ + ) + ); + } + + @Test + void doNotChangeGradleKotlinDslJvmTargetOutsideKotlinBlock() { + rewriteRun( + buildGradleKts( + """ + plugins { + kotlin("jvm") version "1.9.24" + } + val jvmTarget = "11" + """ + ) + ); + } + + @Test + void doNotDowngradeMaven() { + rewriteRun( + pomXml( + //language=xml + """ + + 4.0.0 + org.example + demo + 1.0.0 + + + + org.jetbrains.kotlin + kotlin-maven-plugin + 2.0.0 + + 25 + + + + + + """ + ) + ); + } + + @Test + void doNotChangeNonKotlinMavenPlugin() { + rewriteRun( + pomXml( + //language=xml + """ + + 4.0.0 + org.example + demo + 1.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 11 + + + + + + """ + ) + ); + } +} From c3b454dea3c944bea3f252a2268114a128957186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Merlin=20B=C3=B6gershausen?= Date: Mon, 1 Jun 2026 09:23:59 +0200 Subject: [PATCH 2/2] Only bump string jvmTarget inside the legacy kotlinOptions block A string jvmTarget value is only valid in the legacy kotlinOptions DSL; in compilerOptions jvmTarget is a Property, so a String assignment does not compile. UpgradeKotlinJvmTargetVersion now distinguishes the enclosing block: it bumps a string literal only inside kotlinOptions, and inside compilerOptions acts only on the JvmTarget.JVM_X enum and jvmTarget.set(...) provider forms. A stray string inside compilerOptions (already non-compiling input) is left untouched for UseJvmTargetProviderSyntax to convert. --- .../UpgradeKotlinJvmTargetVersion.java | 37 +++++++++++--- .../UpgradeKotlinJvmTargetVersionTest.java | 50 +++++++++++++++++++ 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersion.java b/src/main/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersion.java index bd714a8bc1..911028cfc0 100644 --- a/src/main/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersion.java +++ b/src/main/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersion.java @@ -115,7 +115,9 @@ private static GroovyIsoVisitor gradleGroovyVisitor(String new @Override public J.Assignment visitAssignment(J.Assignment assignment, ExecutionContext ctx) { J.Assignment a = super.visitAssignment(assignment, ctx); - if (!isInsideKotlinCompilerBlock(getCursor())) { + // A string `jvmTarget` is only valid in the legacy `kotlinOptions` block; bumping one inside + // `compilerOptions` would leave a non-compiling String assignment to a `Property`. + if (!"kotlinOptions".equals(enclosingKotlinCompilerBlock(getCursor()))) { return a; } Expression variable = a.getVariable(); @@ -161,7 +163,13 @@ public J.Assignment visitAssignment(J.Assignment assignment, ExecutionContext ct } Expression rhs = a.getAssignment(); if (rhs instanceof J.Literal) { - return bumpLiteralAssignment(a, (J.Literal) rhs, newVersion, target); + // A string-literal `jvmTarget` is only valid in the legacy `kotlinOptions` block. Inside + // `compilerOptions` it is `Property` and a String assignment does not compile, so + // leave such (already-invalid) input untouched — `UseJvmTargetProviderSyntax` converts it. + if ("kotlinOptions".equals(enclosingKotlinCompilerBlock(getCursor()))) { + return bumpLiteralAssignment(a, (J.Literal) rhs, newVersion, target); + } + return a; } if (rhs instanceof J.FieldAccess) { J.FieldAccess fa = (J.FieldAccess) rhs; @@ -200,21 +208,34 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu }; } - // Gradle build scripts lack type attribution, so there is no trait that models "inside the compilerOptions - // block" — walk the cursor ancestry and match the enclosing DSL block by name (matchUnknownTypes=true), the - // same approach `org.openrewrite.gradle.UpdateJavaCompatibility` uses for `java { }` / `sourceCompatibility`. private static boolean isInsideKotlinCompilerBlock(Cursor cursor) { + return enclosingKotlinCompilerBlock(cursor) != null; + } + + /** + * The simple name of the nearest enclosing Kotlin compile-config DSL block (`kotlinOptions` or + * `compilerOptions`), or {@code null} if there is none. Gradle build scripts lack type attribution, so the + * enclosing block is matched by name (matchUnknownTypes=true), the same approach + * `org.openrewrite.gradle.UpdateJavaCompatibility` uses for `java { }` / `sourceCompatibility`. + *

+ * The distinction matters: `jvmTarget` is a `String` in the legacy `kotlinOptions` DSL but a + * `Property` in `compilerOptions`, so a string-literal value is only valid under `kotlinOptions`. + */ + private static @Nullable String enclosingKotlinCompilerBlock(Cursor cursor) { Iterator path = cursor.getPath(); while (path.hasNext()) { Object o = path.next(); if (o instanceof J.MethodInvocation) { J.MethodInvocation mi = (J.MethodInvocation) o; - if (KOTLIN_OPTIONS.matches(mi, true) || COMPILER_OPTIONS.matches(mi, true)) { - return true; + if (KOTLIN_OPTIONS.matches(mi, true)) { + return "kotlinOptions"; + } + if (COMPILER_OPTIONS.matches(mi, true)) { + return "compilerOptions"; } } } - return false; + return null; } private static J.Assignment bumpLiteralAssignment(J.Assignment a, J.Literal literal, String newVersion, int target) { diff --git a/src/test/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersionTest.java b/src/test/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersionTest.java index 82f11ca849..efa50cf11b 100644 --- a/src/test/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersionTest.java +++ b/src/test/java/org/openrewrite/java/migrate/UpgradeKotlinJvmTargetVersionTest.java @@ -232,6 +232,56 @@ void doNotDowngradeGradleKotlinDsl() { ); } + @Test + void doNotBumpStringJvmTargetInsideCompilerOptions() { + // A String `jvmTarget` is invalid inside `compilerOptions` (it is a `Property`). Bumping the + // number would leave a still-non-compiling String assignment, so leave this already-invalid input alone; + // `UseJvmTargetProviderSyntax` is responsible for converting it to the provider form. + rewriteRun( + buildGradleKts( + """ + plugins { + kotlin("jvm") version "1.9.24" + } + kotlin { + compilerOptions { + jvmTarget = "11" + } + } + """ + ) + ); + } + + @Test + void bumpStringJvmTargetInsideLegacyKotlinOptions() { + // In the legacy `kotlinOptions` block `jvmTarget` is a String, so bumping the string value is correct. + rewriteRun( + buildGradleKts( + """ + plugins { + kotlin("jvm") version "1.9.24" + } + tasks.withType { + kotlinOptions { + jvmTarget = "11" + } + } + """, + """ + plugins { + kotlin("jvm") version "1.9.24" + } + tasks.withType { + kotlinOptions { + jvmTarget = "21" + } + } + """ + ) + ); + } + @Test void doNotChangeGradleKotlinDslJvmTargetOutsideKotlinBlock() { rewriteRun(