From db406afa678e9839ea012a9eb79482102a185d52 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 31 Jan 2026 00:45:41 +0100 Subject: [PATCH 1/5] Change Docker image version in Java upgrades --- build.gradle.kts | 1 + .../java/migrate/UpgradeJavaVersion.java | 66 +++++++++++++++++-- .../java/migrate/UpgradeJavaVersionTest.java | 43 ++++++++++++ 3 files changed, 104 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a80981b8d1..c9dba8002e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -53,6 +53,7 @@ dependencies { implementation("org.openrewrite:rewrite-json") implementation("org.openrewrite:rewrite-maven") implementation("org.openrewrite:rewrite-gradle") + implementation("org.openrewrite:rewrite-docker") implementation("org.openrewrite.recipe:rewrite-github-actions:$rewriteVersion") implementation("org.openrewrite.recipe:rewrite-java-dependencies:$rewriteVersion") implementation("org.openrewrite.recipe:rewrite-static-analysis:$rewriteVersion") diff --git a/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java b/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java index cc55fbfe4f..041d2212b3 100644 --- a/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java +++ b/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java @@ -21,6 +21,7 @@ import org.openrewrite.Option; import org.openrewrite.Recipe; import org.openrewrite.TreeVisitor; +import org.openrewrite.docker.ChangeFrom; import org.openrewrite.gradle.UpdateJavaCompatibility; import org.openrewrite.java.JavaIsoVisitor; import org.openrewrite.java.marker.JavaVersion; @@ -43,19 +44,72 @@ public class UpgradeJavaVersion extends Recipe { String displayName = "Upgrade Java version"; String description = "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."; + "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."; @Override public List getRecipeList() { - return Arrays.asList( + List recipes = new ArrayList<>(Arrays.asList( new UseMavenCompilerPluginReleaseConfiguration(version), new UpdateMavenProjectPropertyJavaVersion(version), new org.openrewrite.jenkins.UpgradeJavaVersion(version, null), new UpdateJavaCompatibility(version, null, null, false, null), new UpdateSdkMan(String.valueOf(version), null) - ); + )); + recipes.addAll(createDockerImageUpgradeRecipes()); + return recipes; + } + + private List createDockerImageUpgradeRecipes() { + List recipes = new ArrayList<>(); + if (version == null) { // for uninitialized version + return recipes; + } + // Deprecated images -> migrate to eclipse-temurin + String[] deprecatedImages = {"openjdk", "adoptopenjdk"}; + String[] currentImages = { + "eclipse-temurin", "amazoncorretto", "azul/zulu-openjdk", + "bellsoft/liberica-openjdk-debian", "bellsoft/liberica-openjdk-alpine", + "bellsoft/liberica-openjdk-centos", "ibm-semeru-runtimes", "sapmachine" + }; + // Common tag suffixes to preserve when upgrading current images + // Longer suffixes must come before shorter ones to match correctly + String[] commonSuffixes = { + "-jdk-alpine", "-jre-alpine", + "-jdk-noble", "-jre-noble", + "-jdk-jammy", "-jre-jammy", + "-jdk-focal", "-jre-focal", + "-jdk-centos7", "-jre-centos7", + "-jdk-ubi9-minimal", "-jre-ubi9-minimal", + "-jdk-nanoserver", "-jre-nanoserver", + "-jdk-windowsservercore", "-jre-windowsservercore", + "-alpine", + "-jdk", "-jre" + }; + for (int oldVersion = 8; oldVersion < version; oldVersion++) { + // Deprecated images: match specific suffixes first to preserve them + for (String image : deprecatedImages) { + for (String suffix : commonSuffixes) { + recipes.add(new ChangeFrom(image, oldVersion + suffix, null, null, "eclipse-temurin", version + suffix, null, null)); + } + } + // Deprecated images: fall back to wildcard for remaining patterns + for (String image : deprecatedImages) { + recipes.add(new ChangeFrom(image, oldVersion + "*", null, null, "eclipse-temurin", version.toString(), null, null)); + } + // Current images: match specific suffixes first to preserve them + for (String image : currentImages) { + for (String suffix : commonSuffixes) { + recipes.add(new ChangeFrom(image, oldVersion + suffix, null, null, null, version + suffix, null, null)); + } + } + // Current images: fall back to wildcard for remaining patterns + for (String image : currentImages) { + recipes.add(new ChangeFrom(image, oldVersion + "*", null, null, null, version.toString(), null, null)); + } + } + return recipes; } /** @@ -63,7 +117,7 @@ public List getRecipeList() { * * @return Zero estimated time. */ - Duration estimatedEffortPerOccurrence = Duration.ofMinutes( 0 ); + Duration estimatedEffortPerOccurrence = Duration.ofMinutes(0); @Override public TreeVisitor getVisitor() { diff --git a/src/test/java/org/openrewrite/java/migrate/UpgradeJavaVersionTest.java b/src/test/java/org/openrewrite/java/migrate/UpgradeJavaVersionTest.java index 37650961b2..8ab1610080 100644 --- a/src/test/java/org/openrewrite/java/migrate/UpgradeJavaVersionTest.java +++ b/src/test/java/org/openrewrite/java/migrate/UpgradeJavaVersionTest.java @@ -17,6 +17,8 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; import org.openrewrite.DocumentExample; import org.openrewrite.config.CompositeRecipe; import org.openrewrite.java.marker.JavaVersion; @@ -30,6 +32,7 @@ import static org.openrewrite.java.Assertions.java; import static org.openrewrite.java.Assertions.version; import static org.openrewrite.maven.Assertions.pomXml; +import static org.openrewrite.test.SourceSpecs.text; class UpgradeJavaVersionTest implements RewriteTest { @Nested @@ -370,4 +373,44 @@ class Test3 { ); } } + + @Nested + class Docker { + @ParameterizedTest + @CsvSource({ + // Deprecated images migrate to eclipse-temurin + "openjdk, 8, eclipse-temurin, 17, 17", + "openjdk, 11, eclipse-temurin, 17, 17", + "adoptopenjdk, 8, eclipse-temurin, 17, 17", + "adoptopenjdk, 11, eclipse-temurin, 17, 17", + // Deprecated images preserve common suffixes when migrating + "openjdk, 11-jdk, eclipse-temurin, 17-jdk, 17", + "openjdk, 11-jdk-alpine, eclipse-temurin, 17-jdk-alpine, 17", + "adoptopenjdk, 8-jre, eclipse-temurin, 17-jre, 17", + // Current images update tag only + "eclipse-temurin, 8, eclipse-temurin, 17, 17", + "eclipse-temurin, 11, eclipse-temurin, 17, 17", + "amazoncorretto, 8, amazoncorretto, 17, 17", + "amazoncorretto, 11, amazoncorretto, 17, 17", + // Current images preserve common suffixes + "eclipse-temurin, 11-jdk, eclipse-temurin, 17-jdk, 17", + "eclipse-temurin, 11-jre, eclipse-temurin, 17-jre, 17", + "eclipse-temurin, 11-jdk-alpine, eclipse-temurin, 17-jdk-alpine, 17", + "eclipse-temurin, 11-jre-alpine, eclipse-temurin, 17-jre-alpine, 17", + "eclipse-temurin, 11-jdk-jammy, eclipse-temurin, 17-jdk-jammy, 17", + "eclipse-temurin, 11-jdk-focal, eclipse-temurin, 17-jdk-focal, 17", + "amazoncorretto, 11-alpine, amazoncorretto, 17-alpine, 17", + "azul/zulu-openjdk, 11-jdk, azul/zulu-openjdk, 17-jdk, 17", + }) + void upgradeDockerImage(String fromImage, String fromTag, String toImage, String toTag, int targetVersion) { + rewriteRun( + spec -> spec.recipe(new UpgradeJavaVersion(targetVersion)), + text( + "FROM %s:%s".formatted(fromImage, fromTag), + "FROM %s:%s".formatted(toImage, toTag), + spec -> spec.path("Dockerfile") + ) + ); + } + } } From 99b30ade95325c68d1812bfc2e27c0d98546cd15 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 31 Jan 2026 09:58:47 +0100 Subject: [PATCH 2/5] Extract UpgradeDockerImageVersion to separate recipe Move Docker image version upgrade logic from UpgradeJavaVersion into its own dedicated recipe class with corresponding tests. Co-Authored-By: Claude Opus 4.5 --- .../migrate/UpgradeDockerImageVersion.java | 99 +++++++++++++++++++ .../java/migrate/UpgradeJavaVersion.java | 67 ++----------- .../resources/META-INF/rewrite/recipes.csv | 21 ++-- .../UpgradeDockerImageVersionTest.java | 62 ++++++++++++ .../java/migrate/UpgradeJavaVersionTest.java | 42 -------- 5 files changed, 181 insertions(+), 110 deletions(-) create mode 100644 src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java create mode 100644 src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java diff --git a/src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java b/src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java new file mode 100644 index 0000000000..0e3f9e37ca --- /dev/null +++ b/src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java @@ -0,0 +1,99 @@ +/* + * Copyright 2024 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.openrewrite.Option; +import org.openrewrite.Recipe; +import org.openrewrite.docker.ChangeFrom; + +import java.util.ArrayList; +import java.util.List; + +@EqualsAndHashCode(callSuper = false) +@Value +public class UpgradeDockerImageVersion extends Recipe { + + @Option(displayName = "Java version", + description = "The Java version to upgrade to.", + example = "11") + Integer version; + + @Override + public String getDisplayName() { + return "Upgrade Docker image Java version"; + } + + @Override + public String getDescription() { + return "Upgrade Docker image tags to use the specified Java version. " + + "Updates common Java Docker images including eclipse-temurin, amazoncorretto, azul/zulu-openjdk, " + + "and others. Also migrates deprecated images (openjdk, adoptopenjdk) to eclipse-temurin."; + } + + @Override + public List getRecipeList() { + List recipes = new ArrayList<>(); + if (version == null) { // for uninitialized version + return recipes; + } + // Deprecated images -> migrate to eclipse-temurin + String[] deprecatedImages = {"openjdk", "adoptopenjdk"}; + String[] currentImages = { + "eclipse-temurin", "amazoncorretto", "azul/zulu-openjdk", + "bellsoft/liberica-openjdk-debian", "bellsoft/liberica-openjdk-alpine", + "bellsoft/liberica-openjdk-centos", "ibm-semeru-runtimes", "sapmachine" + }; + // Common tag suffixes to preserve when upgrading current images + // Longer suffixes must come before shorter ones to match correctly + String[] commonSuffixes = { + "-jdk-alpine", "-jre-alpine", + "-jdk-noble", "-jre-noble", + "-jdk-jammy", "-jre-jammy", + "-jdk-focal", "-jre-focal", + "-jdk-centos7", "-jre-centos7", + "-jdk-ubi9-minimal", "-jre-ubi9-minimal", + "-jdk-nanoserver", "-jre-nanoserver", + "-jdk-windowsservercore", "-jre-windowsservercore", + "-alpine", + "-jdk", "-jre" + }; + for (int oldVersion = 8; oldVersion < version; oldVersion++) { + // Deprecated images: match specific suffixes first to preserve them + for (String image : deprecatedImages) { + for (String suffix : commonSuffixes) { + recipes.add(new ChangeFrom(image, oldVersion + suffix, null, null, "eclipse-temurin", version + suffix, null, null)); + } + } + // Deprecated images: fall back to wildcard for remaining patterns + for (String image : deprecatedImages) { + recipes.add(new ChangeFrom(image, oldVersion + "*", null, null, "eclipse-temurin", version.toString(), null, null)); + } + // Current images: match specific suffixes first to preserve them + for (String image : currentImages) { + for (String suffix : commonSuffixes) { + recipes.add(new ChangeFrom(image, oldVersion + suffix, null, null, null, version + suffix, null, null)); + } + } + // Current images: fall back to wildcard for remaining patterns + for (String image : currentImages) { + recipes.add(new ChangeFrom(image, oldVersion + "*", null, null, null, version.toString(), null, null)); + } + } + return recipes; + } +} diff --git a/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java b/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java index 041d2212b3..368fe72bfd 100644 --- a/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java +++ b/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java @@ -21,7 +21,6 @@ import org.openrewrite.Option; import org.openrewrite.Recipe; import org.openrewrite.TreeVisitor; -import org.openrewrite.docker.ChangeFrom; import org.openrewrite.gradle.UpdateJavaCompatibility; import org.openrewrite.java.JavaIsoVisitor; import org.openrewrite.java.marker.JavaVersion; @@ -30,7 +29,11 @@ import org.openrewrite.maven.UseMavenCompilerPluginReleaseConfiguration; import java.time.Duration; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; @EqualsAndHashCode(callSuper = false) @Value @@ -50,66 +53,14 @@ public class UpgradeJavaVersion extends Recipe { @Override public List getRecipeList() { - List recipes = new ArrayList<>(Arrays.asList( + return Arrays.asList( new UseMavenCompilerPluginReleaseConfiguration(version), new UpdateMavenProjectPropertyJavaVersion(version), new org.openrewrite.jenkins.UpgradeJavaVersion(version, null), new UpdateJavaCompatibility(version, null, null, false, null), - new UpdateSdkMan(String.valueOf(version), null) - )); - recipes.addAll(createDockerImageUpgradeRecipes()); - return recipes; - } - - private List createDockerImageUpgradeRecipes() { - List recipes = new ArrayList<>(); - if (version == null) { // for uninitialized version - return recipes; - } - // Deprecated images -> migrate to eclipse-temurin - String[] deprecatedImages = {"openjdk", "adoptopenjdk"}; - String[] currentImages = { - "eclipse-temurin", "amazoncorretto", "azul/zulu-openjdk", - "bellsoft/liberica-openjdk-debian", "bellsoft/liberica-openjdk-alpine", - "bellsoft/liberica-openjdk-centos", "ibm-semeru-runtimes", "sapmachine" - }; - // Common tag suffixes to preserve when upgrading current images - // Longer suffixes must come before shorter ones to match correctly - String[] commonSuffixes = { - "-jdk-alpine", "-jre-alpine", - "-jdk-noble", "-jre-noble", - "-jdk-jammy", "-jre-jammy", - "-jdk-focal", "-jre-focal", - "-jdk-centos7", "-jre-centos7", - "-jdk-ubi9-minimal", "-jre-ubi9-minimal", - "-jdk-nanoserver", "-jre-nanoserver", - "-jdk-windowsservercore", "-jre-windowsservercore", - "-alpine", - "-jdk", "-jre" - }; - for (int oldVersion = 8; oldVersion < version; oldVersion++) { - // Deprecated images: match specific suffixes first to preserve them - for (String image : deprecatedImages) { - for (String suffix : commonSuffixes) { - recipes.add(new ChangeFrom(image, oldVersion + suffix, null, null, "eclipse-temurin", version + suffix, null, null)); - } - } - // Deprecated images: fall back to wildcard for remaining patterns - for (String image : deprecatedImages) { - recipes.add(new ChangeFrom(image, oldVersion + "*", null, null, "eclipse-temurin", version.toString(), null, null)); - } - // Current images: match specific suffixes first to preserve them - for (String image : currentImages) { - for (String suffix : commonSuffixes) { - recipes.add(new ChangeFrom(image, oldVersion + suffix, null, null, null, version + suffix, null, null)); - } - } - // Current images: fall back to wildcard for remaining patterns - for (String image : currentImages) { - recipes.add(new ChangeFrom(image, oldVersion + "*", null, null, null, version.toString(), null, null)); - } - } - return recipes; + new UpdateSdkMan(String.valueOf(version), null), + new UpgradeDockerImageVersion(version) + ); } /** diff --git a/src/main/resources/META-INF/rewrite/recipes.csv b/src/main/resources/META-INF/rewrite/recipes.csv index 0687fb17a9..05261310fa 100644 --- a/src/main/resources/META-INF/rewrite/recipes.csv +++ b/src/main/resources/META-INF/rewrite/recipes.csv @@ -22,7 +22,8 @@ maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.R maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.ReplaceLocalizedStreamMethods,Replace `getLocalizedInputStream` and `getLocalizedOutputStream` with direct assignment,Replaces `Runtime.getLocalizedInputStream(InputStream)` and `Runtime.getLocalizedOutputStream(OutputStream)` with their direct arguments. This modification is made because the previous implementation of `getLocalizedInputStream` and `getLocalizedOutputStream` merely returned the arguments provided.,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"":""localizedInputStreamMethodMatcher"",""type"":""String"",""displayName"":""Method pattern to replace"",""description"":""The method pattern to match and replace."",""example"":""java.lang.Runtime getLocalizedInputStream(java.io.InputStream)"",""value"":""java.lang.Runtime getLocalizedInputStream(java.io.InputStream)""},{""name"":""localizedOutputStreamMethodMatcher"",""type"":""String"",""displayName"":""Method pattern to replace"",""description"":""The method pattern to match and replace."",""example"":""java.lang.Runtime getLocalizedOutputStream(java.io.OutputStream)"",""value"":""java.lang.Runtime getLocalizedOutputStream(java.io.OutputStream)""}]", maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.ReplaceStringLiteralValue,Replace `String` literal,Replace the value of a complete `String` literal.,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"":""oldLiteralValue"",""type"":""String"",""displayName"":""Old literal `String` value"",""description"":""The `String` value to replace."",""example"":""apple"",""required"":true},{""name"":""newLiteralValue"",""type"":""String"",""displayName"":""New literal `String` value"",""description"":""The `String` value to replace with."",""example"":""orange"",""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."",""example"":""17""},{""name"":""newDistribution"",""type"":""String"",""displayName"":""Distribution"",""description"":""The JVM distribution to use."",""example"":""tem""}]", -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.",11,,,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.UpgradeDockerImageVersion,Upgrade Docker image Java version,"Upgrade Docker image tags to use the specified Java version. Updates common Java Docker images including eclipse-temurin, amazoncorretto, azul/zulu-openjdk, and others. Also migrates deprecated images (openjdk, adoptopenjdk) to eclipse-temurin.",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 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.",13,,,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.UseJavaUtilBase64,Prefer `java.util.Base64` instead of `sun.misc`,Prefer `java.util.Base64` instead of using `sun.misc` in Java 8 or higher. `sun.misc` is not exported by the Java module system and accessing this class will result in a warning in Java 11 and an error in Java 17.,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"":""useMimeCoder"",""type"":""boolean"",""displayName"":""Use Mime Coder"",""description"":""Use `Base64.getMimeEncoder()/getMimeDecoder()` instead of `Base64.getEncoder()/getDecoder()`."",""example"":""false"",""value"":false}]", 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.AddStaticVariableOnProducerSessionBean,Adds `static` modifier to `@Produces` fields that are in session beans,"Ensures that the fields annotated with `@Produces` which is inside the session bean (`@Stateless`, `@Stateful`, or `@Singleton`) are declared `static`.",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.,, @@ -42,14 +43,14 @@ maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.C 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.",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.javaee7,Migrate to JavaEE7,"These recipes help with the Migration to Java EE 7, flagging and updating deprecated methods.",15,,,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.",35,,,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.",435,,,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"",""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.,13,,,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.",1639,,,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"",""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.,1215,,,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.,11,,,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"",""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.,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.RemovedPolicy,Replace `javax.security.auth.Policy` with `java.security.Policy`,The `javax.security.auth.Policy` class is not available from Java SE 11 onwards.,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.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.",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.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.",573,,,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"",""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.,13,,,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.",5379,,,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"",""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.,3615,,,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.,15,,,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"",""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.,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.RemovedLegacySunJSSEProviderName,Use `SunJSSE` instead of `com.sun.net.ssl.internal.ssl.Provider`,The `com.sun.net.ssl.internal.ssl.Provider` provider name was removed.,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.,, @@ -69,13 +70,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.,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.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.,13,,,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.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.",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.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.,655,,,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"",""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.,13,,,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.,10663,,,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"",""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.,5215,,,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.,11,,,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"",""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()`.,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.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.,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.,, 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.,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.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.,743,,,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"",""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.,17553,,,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"",""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`.,9,,,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`.,9,,,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`.,9,,,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.,, @@ -86,7 +87,7 @@ maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.U 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`.,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.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.,55,,,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"",""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.,19,,,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.,103,,,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"",""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.,105,,,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"",""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.NoGuavaAtomicsNewReference,Prefer `new AtomicReference<>()`,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.NoGuavaCollections2Transform,Prefer `Collection.stream().map(Function)` over `Collections2.transform`,"Prefer `Collection.stream().map(Function)` over `Collections2.transform(Collection, Function)`.",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.NoGuavaCreateTempDir,Prefer `Files#createTempDirectory()`,Replaces Guava `Files#createTempDir()` with Java `Files#createTempDirectory(..)`. Transformations are limited to scopes throwing or catching `java.io.IOException`.,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.,, @@ -322,7 +323,7 @@ maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.l maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.lang.SwitchExpressionYieldToArrow,Convert switch expression yield to arrow,Convert switch expressions with colon cases and yield statements to arrow syntax. This recipe is only applicable for Java 21 and later.,1,,`java.lang` APIs,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.lang.ThreadStopUnsupported,"Replace `Thread.resume()`, `Thread.stop()`, and `Thread.suspend()` with `throw new UnsupportedOperationException()`","`Thread.resume()`, `Thread.stop()`, and `Thread.suspend()` always throws a `new UnsupportedOperationException` in Java 21+. This recipe makes that explicit, as the migration is more complicated. See https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/doc-files/threadPrimitiveDeprecation.html .",1,,`java.lang` APIs,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.lang.UseStringIsEmptyRecipe,Replace `0 < s.length()` with `!s.isEmpty()`,Replace `0 < s.length()` and `s.length() != 0` with `!s.isEmpty()`.,1,,`java.lang` APIs,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.lang.UseTextBlocks,Use text blocks,Text blocks are easier to read than concatenated strings.,1,,`java.lang` APIs,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"":""convertStringsWithoutNewlines"",""type"":""boolean"",""displayName"":""Whether to convert strings without newlines (the default value is true)."",""description"":""Whether or not strings without newlines should be converted to text block when processing code. The default value is true."",""example"":""true"",""value"":true}]", +maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.lang.UseTextBlocks,Use text blocks,Text blocks are easier to read than concatenated strings.,1,,`java.lang` APIs,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"":""convertStringsWithoutNewlines"",""type"":""boolean"",""displayName"":""Whether to convert strings without newlines (the default value is true)."",""description"":""Whether or not strings without newlines should be converted to text block when processing code. The default value is true."",""example"":""true"",""value"":true},{""name"":""avoidLineContinuations"",""type"":""boolean"",""displayName"":""Whether to avoid line continuation escape sequences."",""description"":""When enabled, the recipe avoids using `\\` line continuation escapes in text blocks where the content contains newlines. Non-newline-joined strings are placed on the same text block line instead. The default value is false."",""example"":""true"",""value"":false}]", maven,org.openrewrite.recipe:rewrite-migrate-java,org.openrewrite.java.migrate.lang.JavaLangAPIs,Use modernized `java.lang` APIs,"Certain Java lang APIs have become deprecated and their usages changed, necessitating usage changes.",31,,`java.lang` APIs,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.lang.MigrateCharacterIsJavaLetterToIsJavaIdentifierStart,Use `Character#isJavaIdentifierStart(char)`,Use `Character#isJavaIdentifierStart(char)` instead of the deprecated `Character#isJavaLetter(char)` in Java 1.1 or higher.,3,,`java.lang` APIs,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.lang.MigrateCharacterIsJavaLetterOrDigitToIsJavaIdentifierPart,Use `Character#isJavaIdentifierPart(char)`,Use `Character#isJavaIdentifierPart(char)` instead of the deprecated `Character#isJavaLetterOrDigit(char)` in Java 1.1 or higher.,3,,`java.lang` APIs,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.,, diff --git a/src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java b/src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java new file mode 100644 index 0000000000..821dd578eb --- /dev/null +++ b/src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2024 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.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.openrewrite.test.RewriteTest; + +import static org.openrewrite.test.SourceSpecs.text; + +class UpgradeDockerImageVersionTest implements RewriteTest { + + @ParameterizedTest + @CsvSource({ + // Deprecated images migrate to eclipse-temurin + "openjdk, 8, eclipse-temurin, 17, 17", + "openjdk, 11, eclipse-temurin, 17, 17", + "adoptopenjdk, 8, eclipse-temurin, 17, 17", + "adoptopenjdk, 11, eclipse-temurin, 17, 17", + // Deprecated images preserve common suffixes when migrating + "openjdk, 11-jdk, eclipse-temurin, 17-jdk, 17", + "openjdk, 11-jdk-alpine, eclipse-temurin, 17-jdk-alpine, 17", + "adoptopenjdk, 8-jre, eclipse-temurin, 17-jre, 17", + // Current images update tag only + "eclipse-temurin, 8, eclipse-temurin, 17, 17", + "eclipse-temurin, 11, eclipse-temurin, 17, 17", + "amazoncorretto, 8, amazoncorretto, 17, 17", + "amazoncorretto, 11, amazoncorretto, 17, 17", + // Current images preserve common suffixes + "eclipse-temurin, 11-jdk, eclipse-temurin, 17-jdk, 17", + "eclipse-temurin, 11-jre, eclipse-temurin, 17-jre, 17", + "eclipse-temurin, 11-jdk-alpine, eclipse-temurin, 17-jdk-alpine, 17", + "eclipse-temurin, 11-jre-alpine, eclipse-temurin, 17-jre-alpine, 17", + "eclipse-temurin, 11-jdk-jammy, eclipse-temurin, 17-jdk-jammy, 17", + "eclipse-temurin, 11-jdk-focal, eclipse-temurin, 17-jdk-focal, 17", + "amazoncorretto, 11-alpine, amazoncorretto, 17-alpine, 17", + "azul/zulu-openjdk, 11-jdk, azul/zulu-openjdk, 17-jdk, 17", + }) + void upgradeDockerImage(String fromImage, String fromTag, String toImage, String toTag, int targetVersion) { + rewriteRun( + spec -> spec.recipe(new UpgradeDockerImageVersion(targetVersion)), + text( + "FROM %s:%s".formatted(fromImage, fromTag), + "FROM %s:%s".formatted(toImage, toTag), + spec -> spec.path("Dockerfile") + ) + ); + } +} diff --git a/src/test/java/org/openrewrite/java/migrate/UpgradeJavaVersionTest.java b/src/test/java/org/openrewrite/java/migrate/UpgradeJavaVersionTest.java index 8ab1610080..3ff033069a 100644 --- a/src/test/java/org/openrewrite/java/migrate/UpgradeJavaVersionTest.java +++ b/src/test/java/org/openrewrite/java/migrate/UpgradeJavaVersionTest.java @@ -17,8 +17,6 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; import org.openrewrite.DocumentExample; import org.openrewrite.config.CompositeRecipe; import org.openrewrite.java.marker.JavaVersion; @@ -32,7 +30,6 @@ import static org.openrewrite.java.Assertions.java; import static org.openrewrite.java.Assertions.version; import static org.openrewrite.maven.Assertions.pomXml; -import static org.openrewrite.test.SourceSpecs.text; class UpgradeJavaVersionTest implements RewriteTest { @Nested @@ -374,43 +371,4 @@ class Test3 { } } - @Nested - class Docker { - @ParameterizedTest - @CsvSource({ - // Deprecated images migrate to eclipse-temurin - "openjdk, 8, eclipse-temurin, 17, 17", - "openjdk, 11, eclipse-temurin, 17, 17", - "adoptopenjdk, 8, eclipse-temurin, 17, 17", - "adoptopenjdk, 11, eclipse-temurin, 17, 17", - // Deprecated images preserve common suffixes when migrating - "openjdk, 11-jdk, eclipse-temurin, 17-jdk, 17", - "openjdk, 11-jdk-alpine, eclipse-temurin, 17-jdk-alpine, 17", - "adoptopenjdk, 8-jre, eclipse-temurin, 17-jre, 17", - // Current images update tag only - "eclipse-temurin, 8, eclipse-temurin, 17, 17", - "eclipse-temurin, 11, eclipse-temurin, 17, 17", - "amazoncorretto, 8, amazoncorretto, 17, 17", - "amazoncorretto, 11, amazoncorretto, 17, 17", - // Current images preserve common suffixes - "eclipse-temurin, 11-jdk, eclipse-temurin, 17-jdk, 17", - "eclipse-temurin, 11-jre, eclipse-temurin, 17-jre, 17", - "eclipse-temurin, 11-jdk-alpine, eclipse-temurin, 17-jdk-alpine, 17", - "eclipse-temurin, 11-jre-alpine, eclipse-temurin, 17-jre-alpine, 17", - "eclipse-temurin, 11-jdk-jammy, eclipse-temurin, 17-jdk-jammy, 17", - "eclipse-temurin, 11-jdk-focal, eclipse-temurin, 17-jdk-focal, 17", - "amazoncorretto, 11-alpine, amazoncorretto, 17-alpine, 17", - "azul/zulu-openjdk, 11-jdk, azul/zulu-openjdk, 17-jdk, 17", - }) - void upgradeDockerImage(String fromImage, String fromTag, String toImage, String toTag, int targetVersion) { - rewriteRun( - spec -> spec.recipe(new UpgradeJavaVersion(targetVersion)), - text( - "FROM %s:%s".formatted(fromImage, fromTag), - "FROM %s:%s".formatted(toImage, toTag), - spec -> spec.path("Dockerfile") - ) - ); - } - } } From 2636f2f7c6d8eee6fe09b9496a7993b30111e92c Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 31 Jan 2026 10:05:38 +0100 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../java/migrate/UpgradeDockerImageVersion.java | 14 ++++---------- .../java/migrate/UpgradeJavaVersion.java | 6 +----- .../migrate/UpgradeDockerImageVersionTest.java | 2 +- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java b/src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java index 0e3f9e37ca..ada0d5221d 100644 --- a/src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java +++ b/src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java @@ -33,16 +33,10 @@ public class UpgradeDockerImageVersion extends Recipe { example = "11") Integer version; - @Override - public String getDisplayName() { - return "Upgrade Docker image Java version"; - } - - @Override - public String getDescription() { - return "Upgrade Docker image tags to use the specified Java version. " + - "Updates common Java Docker images including eclipse-temurin, amazoncorretto, azul/zulu-openjdk, " + - "and others. Also migrates deprecated images (openjdk, adoptopenjdk) to eclipse-temurin."; + String displayName = "Upgrade Docker image Java version"; + String description = "Upgrade Docker image tags to use the specified Java version. " + + "Updates common Java Docker images including eclipse-temurin, amazoncorretto, azul/zulu-openjdk, " + + "and others. Also migrates deprecated images (openjdk, adoptopenjdk) to eclipse-temurin."; } @Override diff --git a/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java b/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java index 368fe72bfd..8b81ca76a7 100644 --- a/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java +++ b/src/main/java/org/openrewrite/java/migrate/UpgradeJavaVersion.java @@ -29,11 +29,7 @@ import org.openrewrite.maven.UseMavenCompilerPluginReleaseConfiguration; import java.time.Duration; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; @EqualsAndHashCode(callSuper = false) @Value diff --git a/src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java b/src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java index 821dd578eb..adbf57e654 100644 --- a/src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java +++ b/src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java @@ -23,7 +23,6 @@ class UpgradeDockerImageVersionTest implements RewriteTest { - @ParameterizedTest @CsvSource({ // Deprecated images migrate to eclipse-temurin "openjdk, 8, eclipse-temurin, 17, 17", @@ -49,6 +48,7 @@ class UpgradeDockerImageVersionTest implements RewriteTest { "amazoncorretto, 11-alpine, amazoncorretto, 17-alpine, 17", "azul/zulu-openjdk, 11-jdk, azul/zulu-openjdk, 17-jdk, 17", }) + @ParameterizedTest void upgradeDockerImage(String fromImage, String fromTag, String toImage, String toTag, int targetVersion) { rewriteRun( spec -> spec.recipe(new UpgradeDockerImageVersion(targetVersion)), From b2e66e9980d334cc621e2e2ba687f6926c8c1082 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 31 Jan 2026 10:12:41 +0100 Subject: [PATCH 4/5] Change Docker image version in Java upgrades --- .../java/migrate/UpgradeDockerImageVersionTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java b/src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java index adbf57e654..339de24414 100644 --- a/src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java +++ b/src/test/java/org/openrewrite/java/migrate/UpgradeDockerImageVersionTest.java @@ -19,7 +19,7 @@ import org.junit.jupiter.params.provider.CsvSource; import org.openrewrite.test.RewriteTest; -import static org.openrewrite.test.SourceSpecs.text; +import static org.openrewrite.docker.Assertions.docker; class UpgradeDockerImageVersionTest implements RewriteTest { @@ -52,10 +52,9 @@ class UpgradeDockerImageVersionTest implements RewriteTest { void upgradeDockerImage(String fromImage, String fromTag, String toImage, String toTag, int targetVersion) { rewriteRun( spec -> spec.recipe(new UpgradeDockerImageVersion(targetVersion)), - text( + docker( "FROM %s:%s".formatted(fromImage, fromTag), - "FROM %s:%s".formatted(toImage, toTag), - spec -> spec.path("Dockerfile") + "FROM %s:%s".formatted(toImage, toTag) ) ); } From 280b8e3c391d1d69f94752aebb3f6f72bead3c7b Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 31 Jan 2026 10:47:27 +0100 Subject: [PATCH 5/5] Apply suggestions from code review --- .../org/openrewrite/java/migrate/UpgradeDockerImageVersion.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java b/src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java index ada0d5221d..1630dcbd19 100644 --- a/src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java +++ b/src/main/java/org/openrewrite/java/migrate/UpgradeDockerImageVersion.java @@ -37,7 +37,6 @@ public class UpgradeDockerImageVersion extends Recipe { String description = "Upgrade Docker image tags to use the specified Java version. " + "Updates common Java Docker images including eclipse-temurin, amazoncorretto, azul/zulu-openjdk, " + "and others. Also migrates deprecated images (openjdk, adoptopenjdk) to eclipse-temurin."; - } @Override public List getRecipeList() {