Change Maven parent

Apache 2.0

Change the parent pom of a Maven pom.xml by matching the existing parent via groupId and artifactId, and updating it to a new groupId, artifactId, version, and optional relativePath. Also updates the project to retain dependency management and properties previously inherited from the old parent that are no longer provided by the new parent. Only what the project uses is retained: a managed version is copied in only for a dependency that this pom or one of its modules declares without a version, and a property only when the pom references it. Removes redundant dependency versions already managed by the new parent.

org.openrewrite.maven.ChangeParentPom

Required

The group ID of the Maven parent pom to be changed away from.

The artifact ID of the maven parent pom to be changed away from.

An exact version number or node-style semver selector used to select the version number.

Optional

The group ID of the new maven parent pom to be adopted. If this argument is omitted it defaults to the value of oldGroupId.

The artifact ID of the new maven parent pom to be adopted. If this argument is omitted it defaults to the value of oldArtifactId.

The relativePath of the maven parent pom to be changed away from. Use an empty String to match <relativePath />, use ../pom.xml to match the default value.

New relative path attribute for parent lookup.

Allows version selection to be extended beyond the original Node Semver semantics. So for example,Setting 'version' to "25-29" can be paired with a metadata pattern of "-jre" to select Guava 29.0-jre

allowVersionDowngradesBoolean

If the new parent has the same group/artifact, this flag can be used to only upgrade the version if the target version is newer than the current.

Accepts a list of GAVs that should be retained when calling RemoveRedundantDependencyVersions. Separate values with commas.

mod run . --recipe=org.openrewrite.maven.ChangeParentPom \ -P oldGroupId=org.springframework.boot \ -P oldArtifactId=spring-boot-starter-parent \ -P newVersion=29.X

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.