Skip to main content

Find Relocated Dependencies

To identify dependencies in your project that have been relocated to new group IDs or artifact IDs, you can use the OpenRewrite recipe org.openrewrite.java.dependencies.RelocatedDependencyCheck from rewrite-java-dependencies.

This recipe searches your project's dependencies for artifacts that have been moved to new Maven coordinates, helping you discover when libraries have changed their group ID or artifact ID. This is common when projects change ownership, restructure their modules, or move to new organizations. The recipe generates a data table showing all relocated dependencies found.

You can run the search recipe using one of the following methods.

The Moderne CLI allows you to run OpenRewrite recipes on your project without needing to modify your build files, against serialized Lossless Semantic Tree (LST) of your project for a considerable performance boost & across projects.

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

  1. If project serialized Lossless Semantic Tree is not yet available locally, then build the LST. This is only needed the first time, or after extensive changes:
shell
mod build ~/workspace/
  1. If the recipe is not available locally yet, then you can install it once using:
shell
mod config recipes jar install org.openrewrite.recipe:rewrite-java-dependencies:LATEST
  1. Run the recipe.
shell
mod run ~/workspace/ --recipe org.openrewrite.java.dependencies.RelocatedDependencyCheck

Analyze the Results

After running the recipe, you will find a data table for RelocatedDependencyReport in the target/rewrite/datatables/ directory for Maven, or build for Gradle build, or in the output directory specified for the Moderne CLI. You will also see relocated dependencies called out in the source code.