Skip to main content

Add explicit transitive dependencies

org.openrewrite.java.dependencies.AddExplicitTransitiveDependencies

Detects when Java source code or configuration files reference types from transitive Maven dependencies and promotes those transitive dependencies to explicit direct dependencies in the pom.xml. This ensures the build is resilient against changes in transitive dependency trees of upstream libraries.

Recipe source

This recipe is only available to users of Moderne.

This recipe is available under the Moderne Proprietary License.

Options

TypeNameDescriptionExample
ListignoredDependenciesOptional. A list of groupId:artifactId glob patterns for dependencies that should not be promoted, even if they appear to be used transitively. For example, com.google.*:* would ignore all Google dependencies, and *:lombok would ignore Lombok regardless of group ID.org.projectlombok:lombok,com.google.*:*

Usage

This recipe has no required configuration options. Users of Moderne can run it via the Moderne CLI:

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

shell
mod run . --recipe AddExplicitTransitiveDependencies

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

mod config recipes jar install org.openrewrite.recipe:rewrite-java-security:3.26.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

org.openrewrite.java.dependencies.table.PromotedTransitiveDependencies

Transitive dependencies that were promoted to direct dependencies because source code references types from them.

Column NameDescription
GroupThe first part of a dependency coordinate com.google.guava:guava:VERSION.
ArtifactThe second part of a dependency coordinate com.google.guava:guava:VERSION.
VersionThe resolved version that was added.
ScopeThe scope assigned to the promoted dependency (compile or test).
POM pathThe path to the pom.xml file where the dependency was promoted.
EvidenceThe type name or reference that demonstrated usage of this transitive dependency.
Source pathThe path to the source file where the evidence was found.