Skip to content

Commit

Permalink
fix[maven]: update plugin dependencies (#4798)
Browse files Browse the repository at this point in the history
* fix[maven]: update plugin dependencies

* Also change plugin dependencies

---------

Co-authored-by: Tim te Beek <[email protected]>
  • Loading branch information
jonblack and timtebeek authored Dec 18, 2024
1 parent 2882fdc commit 6b2b63c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>com.mycompany.myplugin</groupId>
<artifactId>my-plugin</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
""",
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>com.mycompany.myplugin</groupId>
<artifactId>my-plugin</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
"""
)
);
}
}

0 comments on commit 6b2b63c

Please sign in to comment.