From 02d29d8416bcdbc11197b8ffd077247679da4aca Mon Sep 17 00:00:00 2001 From: Laurens Westerlaken Date: Wed, 29 Oct 2025 11:55:59 +0100 Subject: [PATCH 1/2] Do not intermix java-ee/jakarta migration with java migration, if anything they should be composed together --- .../add-common-annotations-dependencies.yml | 2 +- .../META-INF/rewrite/java-version-17.yml | 26 ------------------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/main/resources/META-INF/rewrite/add-common-annotations-dependencies.yml b/src/main/resources/META-INF/rewrite/add-common-annotations-dependencies.yml index 389e5f8f30..3b163287ae 100644 --- a/src/main/resources/META-INF/rewrite/add-common-annotations-dependencies.yml +++ b/src/main/resources/META-INF/rewrite/add-common-annotations-dependencies.yml @@ -33,7 +33,7 @@ recipeList: newGroupId: jakarta.annotation newArtifactId: jakarta.annotation-api newVersion: 1.3.x - # set explicitly even if managed, as higher versions do not have the javax namespace + # Set explicitly even if managed, as higher versions do not have the javax namespace overrideManagedVersion: true changeManagedDependency: false # Jakarta EE recommends `provided` scope diff --git a/src/main/resources/META-INF/rewrite/java-version-17.yml b/src/main/resources/META-INF/rewrite/java-version-17.yml index 1da448fd01..ff5e73db31 100644 --- a/src/main/resources/META-INF/rewrite/java-version-17.yml +++ b/src/main/resources/META-INF/rewrite/java-version-17.yml @@ -72,8 +72,6 @@ recipeList: artifactId: mapstruct* newVersion: 1.6.x - org.openrewrite.java.migrate.AddLombokMapstructBinding - - org.openrewrite.java.migrate.UpdateJakartaAnnotationsIfForJavax - - org.openrewrite.java.migrate.UpdateJakartaAnnotationsIfExistsForJakarta --- type: specs.openrewrite.org/v1beta/recipe @@ -338,28 +336,4 @@ recipeList: groupId: org.projectlombok artifactId: lombok-mapstruct-binding version: 0.2.0 ---- -# The scanning phase comes before the editing phase, therefor we check if a javax.annotation dependency is on the classpath (with whatever version) -type: specs.openrewrite.org/v1beta/recipe -name: org.openrewrite.java.migrate.UpdateJakartaAnnotationsIfForJavax -displayName: Update `jakarta.annotation-api` dependency if it exists -description: Counteract the `jakarta.annotation-api` by updating to `jakarta` namespace -preconditions: - - org.openrewrite.java.dependencies.search.ModuleHasDependency: - groupIdPattern: javax.annotation - artifactIdPattern: javax.annotation-api -recipeList: - - org.openrewrite.java.migrate.jakarta.JavaxAnnotationMigrationToJakartaAnnotation ---- -type: specs.openrewrite.org/v1beta/recipe -name: org.openrewrite.java.migrate.UpdateJakartaAnnotationsIfExistsForJakarta -displayName: Update `jakarta.annotation-api` dependency if it exists -description: Counteract the `jakarta.annotation-api` by updating to `jakarta` namespace -preconditions: - - org.openrewrite.java.dependencies.search.ModuleHasDependency: - groupIdPattern: jakarta.annotation - artifactIdPattern: jakarta.annotation-api - version: 1.3.x -recipeList: - - org.openrewrite.java.migrate.jakarta.JavaxAnnotationMigrationToJakartaAnnotation From a55781315c02a5be74382e527d422b6a01c3016b Mon Sep 17 00:00:00 2001 From: Laurens Westerlaken Date: Wed, 29 Oct 2025 20:12:43 +0100 Subject: [PATCH 2/2] Remove test that no longer makes sense --- .../java/migrate/UpgradeToJava17Test.java | 70 ------------------- 1 file changed, 70 deletions(-) diff --git a/src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java b/src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java index b16d7576f3..756303029e 100644 --- a/src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java +++ b/src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java @@ -504,76 +504,6 @@ void test() throws Exception { ); } - @Issue("https://github.com/openrewrite/rewrite-migrate-java/pull/816") - @Test - void javaxAnnotationApiToJakarta() { - rewriteRun( - spec -> spec.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "javax.annotation-api-1.3.2")), - version( - mavenProject("project", - //language=xml - pomXml( - """ - - 4.0.0 - com.mycompany.app - my-app - 1 - - - javax.annotation - javax.annotation-api - 1.3.2 - - - - """, - """ - - 4.0.0 - com.mycompany.app - my-app - 1 - - 17 - - - - jakarta.annotation - jakarta.annotation-api - 2.0.0 - provided - - - - """ - ), - //language=java - srcMainJava( - java( - """ - import javax.annotation.PostConstruct; - - class A { - @PostConstruct - void init() {} - } - """, - """ - import jakarta.annotation.PostConstruct; - - class A { - @PostConstruct - void init() {} - } - """ - ) - ) - ), - 8) - ); - } - @Test void upgradeSpotbugsPluginVersion() { rewriteRun(