diff --git a/src/main/resources/META-INF/rewrite/jakarta-ee-9.yml b/src/main/resources/META-INF/rewrite/jakarta-ee-9.yml index 097cef5283..e1c93c18e4 100644 --- a/src/main/resources/META-INF/rewrite/jakarta-ee-9.yml +++ b/src/main/resources/META-INF/rewrite/jakarta-ee-9.yml @@ -403,6 +403,12 @@ recipeList: newGroupId: jakarta.inject newArtifactId: jakarta.inject-api newVersion: latest.release + - org.openrewrite.java.dependencies.ChangeDependency: + oldGroupId: javax.inject + oldArtifactId: javax.inject + newGroupId: jakarta.inject + newArtifactId: jakarta.inject-api + newVersion: latest.release - org.openrewrite.java.dependencies.UpgradeDependencyVersion: groupId: jakarta.inject artifactId: jakarta.inject-api @@ -1028,4 +1034,4 @@ preconditions: recipeList: - org.openrewrite.java.dependencies.RemoveDependency: groupId: jakarta.annotation - artifactId: jakarta.annotation-api \ No newline at end of file + artifactId: jakarta.annotation-api diff --git a/src/test/java/org/openrewrite/java/migrate/jakarta/JavaxInjectToJakartaInjectTest.java b/src/test/java/org/openrewrite/java/migrate/jakarta/JavaxInjectToJakartaInjectTest.java new file mode 100644 index 0000000000..34bbda5d53 --- /dev/null +++ b/src/test/java/org/openrewrite/java/migrate/jakarta/JavaxInjectToJakartaInjectTest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2024 the original author or authors. + *
+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * https://www.apache.org/licenses/LICENSE-2.0 + *
+ * 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.jakarta;
+
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.openrewrite.maven.Assertions.pomXml;
+
+class JavaxInjectToJakartaInjectTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipeFromResource(
+ "/META-INF/rewrite/jakarta-ee-9.yml",
+ "org.openrewrite.java.migrate.jakarta.JavaxInjectMigrationToJakartaInject");
+ }
+
+ @Test
+ @DocumentExample
+ void projectWithJavaxInject() {
+ rewriteRun(
+ //language=xml
+ pomXml(
+ """
+