From 6b2b63c718b4c4d12c57d4b50b1d5d21c4f0991c Mon Sep 17 00:00:00 2001 From: Jon Black Date: Wed, 18 Dec 2024 23:42:07 +0100 Subject: [PATCH] fix[maven]: update plugin dependencies (#4798) * fix[maven]: update plugin dependencies * Also change plugin dependencies --------- Co-authored-by: Tim te Beek --- .../ChangeDependencyGroupIdAndArtifactId.java | 2 +- ...ngeDependencyGroupIdAndArtifactIdTest.java | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/ChangeDependencyGroupIdAndArtifactId.java b/rewrite-maven/src/main/java/org/openrewrite/maven/ChangeDependencyGroupIdAndArtifactId.java index 96e6b4a5eaa..4bb4ccce955 100755 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/ChangeDependencyGroupIdAndArtifactId.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/ChangeDependencyGroupIdAndArtifactId.java @@ -175,7 +175,7 @@ public Xml visitTag(Xml.Tag tag, ExecutionContext ctx) { maybeUpdateModel(); return t; } - if (isOldDependencyTag) { + if (isOldDependencyTag || isPluginDependencyTag(oldGroupId, oldArtifactId)) { String groupId = newGroupId; if (groupId != null) { t = changeChildTagValue(t, "groupId", groupId, ctx); diff --git a/rewrite-maven/src/test/java/org/openrewrite/maven/ChangeDependencyGroupIdAndArtifactIdTest.java b/rewrite-maven/src/test/java/org/openrewrite/maven/ChangeDependencyGroupIdAndArtifactIdTest.java index 70bfef61989..a0fb4005f9c 100644 --- a/rewrite-maven/src/test/java/org/openrewrite/maven/ChangeDependencyGroupIdAndArtifactIdTest.java +++ b/rewrite-maven/src/test/java/org/openrewrite/maven/ChangeDependencyGroupIdAndArtifactIdTest.java @@ -1557,4 +1557,71 @@ void changeProfileDependencyGroupIdAndArtifactId() { ) ); } + + @Test + @Issue("https://github.com/openrewrite/rewrite/issues/4779") + void changePluginDependencyGroupIdAndArtifactId() { + rewriteRun( + spec -> spec.recipe(new ChangeDependencyGroupIdAndArtifactId( + "javax.activation", + "javax.activation-api", + "jakarta.activation", + "jakarta.activation-api", + null, + null + )), + pomXml( + """ + + 4.0.0 + com.mycompany.app + my-app + 1 + + + + + com.mycompany.myplugin + my-plugin + 1.0.0 + + + javax.activation + javax.activation-api + 1.2.0 + + + + + + + """, + """ + + 4.0.0 + com.mycompany.app + my-app + 1 + + + + + com.mycompany.myplugin + my-plugin + 1.0.0 + + + jakarta.activation + jakarta.activation-api + 1.2.0 + + + + + + + """ + ) + ); + } }