Add Gradle or Maven dependency
Apache 2.0For a Gradle project, add a dependency to a build.gradle or build.gradle.kts file in the correct configuration based on where it is used. For a Maven project, add a dependency to a pom.xml file in the correct scope based on where it is used.
org. openrewrite. java. dependencies. AddDependencyRequired
The first part of a dependency coordinate com.google.guava:guava:VERSION.
The second part of a dependency coordinate com.google.guava:guava:VERSION.
Optional
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 version to "25-29" can be paired with a metadata pattern of "-jre" to select Guava 29.0-jre.
Used to determine if the dependency will be added and in which scope it should be placed.
A classifier to add. Commonly used to select variants of a library.
For Maven only, a pattern, applied to group IDs, used to determine which other dependencies should have aligned version numbers. Accepts * as a wildcard character.
For Gradle only, the extension of the dependency to add. If omitted Gradle defaults to assuming the type is "jar".
The Gradle dependency configuration name within which to place the dependency. When omitted the configuration will be determined by the Maven scope parameter. If that parameter is also omitted, configuration will be determined based on where types matching onlyIfUsing appear in source code.
The Maven scope within which to place the dependency. When omitted scope will be determined based on where types matching onlyIfUsing appear in source code.
For Maven only, whether to exclude snapshots from consideration when using a semver selector.
For Maven only, the type of dependency to add. If omitted Maven defaults to assuming the type is "jar".
For Maven only, set the value of the <optional> tag. No <optional> tag will be added when this is null.
For Maven only, if enabled, the dependency will not be added if it is already on the classpath as a transitive dependency. Defaults to false.
mod run . --recipe= org. openrewrite. java. dependencies. AddDependency \
-P groupId= com. google. guava \
-P artifactId= guavaInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.