Skip to main content

Change Maven plugin group and artifact ID

org.openrewrite.maven.ChangePluginGroupIdAndArtifactId

Change the groupId and/or the artifactId of a specified Maven plugin. Optionally update the plugin version. This recipe does not perform any validation and assumes all values passed are valid.

Recipe source

GitHub: ChangePluginGroupIdAndArtifactId.java, Issue Tracker, Maven Central

This recipe is available under the Apache License Version 2.0.

Options

TypeNameDescriptionExample
StringoldGroupIdThe old group ID to replace. The group ID is the first part of a plugin coordinate 'com.google.guava:guava:VERSION'. Supports glob expressions.org.openrewrite.recipe
StringoldArtifactIdThe old artifactId to replace. The artifact ID is the second part of a plugin coordinate 'com.google.guava:guava:VERSION'. Supports glob expressions.my-deprecated-maven-plugin
StringnewGroupIdOptional. The new group ID to use.corp.internal.openrewrite.recipe
StringnewArtifactIdOptional. The new artifact ID to use.my-new-maven-plugin
StringnewVersionOptional. An exact version number.29.0

Used by

This recipe is used as part of the following composite recipes:

Example

Parameters
ParameterValue
oldGroupIdio.quarkus
oldArtifactIdquarkus-bootstrap-maven-plugin
newGroupIdnull
newArtifactIdquarkus-extension-maven-plugin
newVersionnull
Before
pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-maven-plugin</artifactId>
<version>3.0.0.Beta1</version>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>profile</id>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-maven-plugin</artifactId>
<version>3.0.0.Beta1</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
After
pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
<version>3.0.0.Beta1</version>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>profile</id>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
<version>3.0.0.Beta1</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

Usage

This recipe has required configuration parameters and can only be run by users of Moderne. To run this recipe, you will need to provide the Moderne CLI run command with the required options. Or, if you'd like to create a declarative recipe, please see the below example of a rewrite.yml file:

rewrite.yml
---
type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.ChangePluginGroupIdAndArtifactIdExample
displayName: Change Maven plugin group and artifact ID example
recipeList:
- org.openrewrite.maven.ChangePluginGroupIdAndArtifactId:
oldGroupId: org.openrewrite.recipe
oldArtifactId: my-deprecated-maven-plugin
newGroupId: corp.internal.openrewrite.recipe
newArtifactId: my-new-maven-plugin
newVersion: 29.0

You will need to have configured the Moderne CLI on your machine before you can run the following command.

shell
mod run . --recipe ChangePluginGroupIdAndArtifactId --recipe-option "oldGroupId=org.openrewrite.recipe" --recipe-option "oldArtifactId=my-deprecated-maven-plugin" --recipe-option "newGroupId=corp.internal.openrewrite.recipe" --recipe-option "newArtifactId=my-new-maven-plugin" --recipe-option "newVersion=29.0"

If the recipe is not available locally, then you can install it using:

mod config recipes jar install org.openrewrite:rewrite-maven:8.74.0

See how this recipe works across multiple open-source repositories

Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.

Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.

Data Tables

Maven metadata failures

org.openrewrite.maven.table.MavenMetadataFailures

Attempts to resolve maven metadata that failed.

Column NameDescription
Group idThe groupId of the artifact for which the metadata download failed.
Artifact idThe artifactId of the artifact for which the metadata download failed.
VersionThe version of the artifact for which the metadata download failed.
Maven repositoryThe URL of the Maven repository that the metadata download failed on.
SnapshotsDoes the repository support snapshots.
ReleasesDoes the repository support releases.
FailureThe reason the metadata download failed.