Skip to content

Commit bb406cf

Browse files
Laurens-Wtimtebeek
andauthored
Do not migrate to Jakarta annotations as part of Java 17 upgrade (#923)
* Do not intermix java-ee/jakarta migration with java migration, if anything they should be composed together * Remove test that no longer makes sense --------- Co-authored-by: Tim te Beek <[email protected]>
1 parent 926d84d commit bb406cf

File tree

3 files changed

+1
-97
lines changed

3 files changed

+1
-97
lines changed

src/main/resources/META-INF/rewrite/add-common-annotations-dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ recipeList:
3333
newGroupId: jakarta.annotation
3434
newArtifactId: jakarta.annotation-api
3535
newVersion: 1.3.x
36-
# set explicitly even if managed, as higher versions do not have the javax namespace
36+
# Set explicitly even if managed, as higher versions do not have the javax namespace
3737
overrideManagedVersion: true
3838
changeManagedDependency: false
3939
# Jakarta EE recommends `provided` scope

src/main/resources/META-INF/rewrite/java-version-17.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ recipeList:
7272
artifactId: mapstruct*
7373
newVersion: 1.6.x
7474
- org.openrewrite.java.migrate.AddLombokMapstructBinding
75-
- org.openrewrite.java.migrate.UpdateJakartaAnnotationsIfForJavax
76-
- org.openrewrite.java.migrate.UpdateJakartaAnnotationsIfExistsForJakarta
7775

7876
---
7977
type: specs.openrewrite.org/v1beta/recipe
@@ -338,28 +336,4 @@ recipeList:
338336
groupId: org.projectlombok
339337
artifactId: lombok-mapstruct-binding
340338
version: 0.2.0
341-
---
342-
# The scanning phase comes before the editing phase, therefor we check if a javax.annotation dependency is on the classpath (with whatever version)
343-
type: specs.openrewrite.org/v1beta/recipe
344-
name: org.openrewrite.java.migrate.UpdateJakartaAnnotationsIfForJavax
345-
displayName: Update `jakarta.annotation-api` dependency if it exists
346-
description: Counteract the `jakarta.annotation-api` by updating to `jakarta` namespace
347-
preconditions:
348-
- org.openrewrite.java.dependencies.search.ModuleHasDependency:
349-
groupIdPattern: javax.annotation
350-
artifactIdPattern: javax.annotation-api
351-
recipeList:
352-
- org.openrewrite.java.migrate.jakarta.JavaxAnnotationMigrationToJakartaAnnotation
353339

354-
---
355-
type: specs.openrewrite.org/v1beta/recipe
356-
name: org.openrewrite.java.migrate.UpdateJakartaAnnotationsIfExistsForJakarta
357-
displayName: Update `jakarta.annotation-api` dependency if it exists
358-
description: Counteract the `jakarta.annotation-api` by updating to `jakarta` namespace
359-
preconditions:
360-
- org.openrewrite.java.dependencies.search.ModuleHasDependency:
361-
groupIdPattern: jakarta.annotation
362-
artifactIdPattern: jakarta.annotation-api
363-
version: 1.3.x
364-
recipeList:
365-
- org.openrewrite.java.migrate.jakarta.JavaxAnnotationMigrationToJakartaAnnotation

src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -504,76 +504,6 @@ void test() throws Exception {
504504
);
505505
}
506506

507-
@Issue("https://github.com/openrewrite/rewrite-migrate-java/pull/816")
508-
@Test
509-
void javaxAnnotationApiToJakarta() {
510-
rewriteRun(
511-
spec -> spec.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "javax.annotation-api-1.3.2")),
512-
version(
513-
mavenProject("project",
514-
//language=xml
515-
pomXml(
516-
"""
517-
<project>
518-
<modelVersion>4.0.0</modelVersion>
519-
<groupId>com.mycompany.app</groupId>
520-
<artifactId>my-app</artifactId>
521-
<version>1</version>
522-
<dependencies>
523-
<dependency>
524-
<groupId>javax.annotation</groupId>
525-
<artifactId>javax.annotation-api</artifactId>
526-
<version>1.3.2</version>
527-
</dependency>
528-
</dependencies>
529-
</project>
530-
""",
531-
"""
532-
<project>
533-
<modelVersion>4.0.0</modelVersion>
534-
<groupId>com.mycompany.app</groupId>
535-
<artifactId>my-app</artifactId>
536-
<version>1</version>
537-
<properties>
538-
<maven.compiler.release>17</maven.compiler.release>
539-
</properties>
540-
<dependencies>
541-
<dependency>
542-
<groupId>jakarta.annotation</groupId>
543-
<artifactId>jakarta.annotation-api</artifactId>
544-
<version>2.0.0</version>
545-
<scope>provided</scope>
546-
</dependency>
547-
</dependencies>
548-
</project>
549-
"""
550-
),
551-
//language=java
552-
srcMainJava(
553-
java(
554-
"""
555-
import javax.annotation.PostConstruct;
556-
557-
class A {
558-
@PostConstruct
559-
void init() {}
560-
}
561-
""",
562-
"""
563-
import jakarta.annotation.PostConstruct;
564-
565-
class A {
566-
@PostConstruct
567-
void init() {}
568-
}
569-
"""
570-
)
571-
)
572-
),
573-
8)
574-
);
575-
}
576-
577507
@Test
578508
void upgradeSpotbugsPluginVersion() {
579509
rewriteRun(

0 commit comments

Comments
 (0)