Skip to main content

Find duplicate classes on the classpath

org.openrewrite.java.dependencies.search.FindDuplicateClasses

Detects classes that appear in multiple dependencies on the classpath. This is similar to what the Maven duplicate-finder-maven-plugin does. Duplicate classes can cause runtime issues when different versions of the same class are loaded.

Recipe source

GitHub: FindDuplicateClasses.java, Issue Tracker, Maven Central

This recipe is available under the Apache License Version 2.0.

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 FindDuplicateClasses

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

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

Duplicate classes report

org.openrewrite.java.dependencies.table.DuplicateClassesReport

Lists classes that appear in multiple dependencies on the classpath

Column NameDescription
Project nameThe project containing the duplicate.
Source setThe source set containing the duplicate (e.g., main, test).
Type nameThe fully qualified name of the duplicate class.
Dependency 1The first dependency containing the class (group:artifact:version).
Dependency 2The second dependency containing the class (group:artifact:version).
Additional dependenciesAny additional dependencies beyond the first two that also contain this class, comma-separated.