Change Gradle or Maven dependency

Apache 2.0

Change the group ID, artifact ID, and/or the version of a specified Gradle or Maven dependency.

org.openrewrite.java.dependencies.ChangeDependency

Required

The old group ID to replace. The group ID is the first part of a dependency coordinate com.google.guava:guava:VERSION. Supports glob expressions.

The old artifact ID to replace. The artifact ID is the second part of a dependency coordinate com.google.guava:guava:VERSION. Supports glob expressions.

Optional

The new group ID to use. Defaults to the existing group ID.

The new artifact ID to use. Defaults to the existing artifact ID.

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

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

overrideManagedVersionBoolean

Explicitly set the version on the new dependency, even when its version is managed. For Maven, this applies when the new dependency has a managed version. For Gradle, this applies when the old dependency has no declared version, regardless of whether the new dependency is managed. The default for this flag is false.

changeManagedDependencyBoolean

Also update the dependency management section. The default for this flag is true.

changePluginDependenciesBoolean

For Maven only, also change dependencies declared inside Maven plugins. Defaults to true.

mod run . --recipe=org.openrewrite.java.dependencies.ChangeDependency \ -P oldGroupId=org.openrewrite.recipe \ -P oldArtifactId=rewrite-testing-frameworks

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