Remove unused dependencies
ProprietaryScans through source code collecting references to types and methods, removing any dependencies that are not used from Maven or Gradle build files. This is best effort and not guaranteed to work well in all cases; false positives are still possible.
This recipe takes reflective access into account: - When reflective access to a class is made unambiguously via a string literal, such as: Class.forName("java.util.List") that is counted correctly. - When reflective access to a class is made ambiguously via anything other than a string literal no dependencies will be removed.
This recipe takes transitive dependencies into account: - When a direct dependency is not used but a transitive dependency it brings in is in use the direct dependency is not removed.
org. openrewrite. java. dependencies. RemoveUnusedDependenciesOptional
A list of groupId:artifactId glob patterns for dependencies that should never be removed, even if they appear unused. For example, com.google.*:* would ignore all Google dependencies, and *:lombok would ignore Lombok regardless of group ID. Separate values with commas.
mod run . --recipe= org. openrewrite. java. dependencies. RemoveUnusedDependenciesInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.