diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginGroupIdAndArtifactId.java b/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginGroupIdAndArtifactId.java
index 25d2e69f2b9..2a772b3d0eb 100755
--- a/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginGroupIdAndArtifactId.java
+++ b/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginGroupIdAndArtifactId.java
@@ -56,6 +56,18 @@ public class ChangePluginGroupIdAndArtifactId extends Recipe {
example = "my-new-maven-plugin",
required = false)
@Nullable
+ String newArtifactId;
+
+ /**
+ * Mistakenly introduced, we restored newArtifactId but let's not break recipes abruptly.
+ */
+ @Option(displayName = "New artifact ID",
+ description = "The new artifact ID to use. Defaults to the existing artifact ID. This property is deprecated, use newArtifactId instead.",
+ example = "my-new-maven-plugin",
+ required = false)
+ @Nullable
+ @Deprecated
+ @SuppressWarnings("DeprecatedIsStillUsed")
String newArtifact;
@Override
@@ -65,7 +77,7 @@ public String getDisplayName() {
@Override
public String getInstanceNameSuffix() {
- return String.format("`%s:%s`", newGroupId, newArtifact);
+ return String.format("`%s:%s`", newGroupId, newArtifactId);
}
@Override
@@ -84,7 +96,9 @@ public Xml visitTag(Xml.Tag tag, ExecutionContext ctx) {
if (newGroupId != null) {
t = changeChildTagValue(t, "groupId", newGroupId, ctx);
}
- if (newArtifact != null) {
+ if (newArtifactId != null) {
+ t = changeChildTagValue(t, "artifactId", newArtifactId, ctx);
+ } else if (newArtifact != null) {
t = changeChildTagValue(t, "artifactId", newArtifact, ctx);
}
if (t != tag) {
diff --git a/rewrite-maven/src/test/java/org/openrewrite/maven/ChangePluginGroupIdAndArtifactIdTest.java b/rewrite-maven/src/test/java/org/openrewrite/maven/ChangePluginGroupIdAndArtifactIdTest.java
index 87b02bfab6a..55147edecf3 100644
--- a/rewrite-maven/src/test/java/org/openrewrite/maven/ChangePluginGroupIdAndArtifactIdTest.java
+++ b/rewrite-maven/src/test/java/org/openrewrite/maven/ChangePluginGroupIdAndArtifactIdTest.java
@@ -31,6 +31,85 @@ void changePluginGroupIdAndArtifactId() {
"io.quarkus",
"quarkus-bootstrap-maven-plugin",
null,
+ "quarkus-extension-maven-plugin",
+ null
+ )),
+ pomXml(
+ """
+
+ 4.0.0
+ com.mycompany.app
+ my-app
+ 1
+
+
+
+ io.quarkus
+ quarkus-bootstrap-maven-plugin
+ 3.0.0.Beta1
+
+
+
+
+
+ profile
+
+
+
+ io.quarkus
+ quarkus-bootstrap-maven-plugin
+ 3.0.0.Beta1
+
+
+
+
+
+
+ """,
+ """
+
+ 4.0.0
+ com.mycompany.app
+ my-app
+ 1
+
+
+
+ io.quarkus
+ quarkus-extension-maven-plugin
+ 3.0.0.Beta1
+
+
+
+
+
+ profile
+
+
+
+ io.quarkus
+ quarkus-extension-maven-plugin
+ 3.0.0.Beta1
+
+
+
+
+
+
+ """
+ )
+ );
+ }
+
+ @DocumentExample
+ @Test
+ void changePluginGroupIdAndArtifactIdDeprecatedNewArtifact() {
+ rewriteRun(
+ spec -> spec.recipe(new ChangePluginGroupIdAndArtifactId(
+ "io.quarkus",
+ "quarkus-bootstrap-maven-plugin",
+ null,
+ null,
"quarkus-extension-maven-plugin"
)),
pomXml(
@@ -107,7 +186,8 @@ void changePluginGroupIdAndArtifactIdNoChange() {
"io.quarkus",
"quarkus-bootstrap-maven-plugin",
null,
- "quarkus-extension-maven-plugin"
+ "quarkus-extension-maven-plugin",
+ null
)),
pomXml(
"""
@@ -152,7 +232,8 @@ void changeManagedPluginGroupIdAndArtifactId() {
"io.quarkus",
"quarkus-bootstrap-maven-plugin",
null,
- "quarkus-extension-maven-plugin"
+ "quarkus-extension-maven-plugin",
+ null
)),
pomXml(
"""
@@ -262,7 +343,8 @@ void changeManagedPluginGroupIdAndArtifactIdNoChange() {
"io.quarkus",
"quarkus-bootstrap-maven-plugin",
null,
- "quarkus-extension-maven-plugin"
+ "quarkus-extension-maven-plugin",
+ null
)),
pomXml(
"""