← All recipes
Open source

Remove direct dependencies that are managed by a BOM with incompatible versions

Recipe IDorg.openrewrite.gradle.RemoveBomManagedDirectDependencies
Artifactorg.openrewrite:rewrite-gradle

Removes directly declared dependencies when they have a version that is incompatible with the version managed by an imported BOM (platform or enforcedPlatform). This is useful during framework upgrades (e.g., Spring Boot) where transitive dependencies receive major version bumps and explicitly declared older versions should be removed to use the BOM-managed versions instead. A dependency is only removed when it would still be reachable transitively through another direct dependency in every configuration where it is declared, so the BOM-managed version takes its place rather than the dependency disappearing from the classpath.

Single recipeApache 2.0

Usage

You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.gradle.RemoveBomManagedDirectDependencies --recipe-option "bomGroupPattern=org.springframework.boot"

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite:rewrite-gradle:8.88.0

Options

NameTypeDescription
bomGroupPatternrequiredStringGroup ID glob pattern for BOMs to consider. For example, org.springframework.boot to match Spring Boot BOMs.
e.g. org.springframework.boot
bomArtifactPatternStringArtifact ID glob pattern for BOMs to consider. For example, *-dependencies to match Spring Boot's BOM.
e.g. *-dependencies
dependencyGroupPatternStringGroup ID glob pattern for dependencies to check against BOM. Use * to match all dependencies.
e.g. *
dependencyArtifactPatternStringArtifact ID glob pattern for dependencies to check against BOM. Use * to match all dependencies.
e.g. *

Data tables

Structured output this recipe can produce.

  • Source files that had resultsSource files that were modified by the recipe run.org.openrewrite.table.SourcesFileResults
  • Source files that had search resultsSearch results that were found during the recipe run.org.openrewrite.table.SearchResults
  • Source files that errored on a recipeThe details of all errors produced by a recipe run.org.openrewrite.table.SourcesFileErrors
  • Recipe performanceStatistics used in analyzing the performance of recipes.org.openrewrite.table.RecipeRunStats