Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 0 additions & 26 deletions src/main/resources/META-INF/rewrite/java-version-17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
</project>
""",
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<properties>
<maven.compiler.release>17</maven.compiler.release>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
"""
),
//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(
Expand Down