Search code examples
javamavenmaven-3

Tool to cleanup or fix pom.xml in Java - Maven project


Over time the java project could be messy. Programmers add and remove libraries. They remove codes but left the dependency in the pom.xml untouched.

Is there a tool out there that can:

  • Scan unneeded dependency within the pom.xml and perhaps suggest those entries for removal?
  • To detect and fix the scope of a dependency?
  • To add or suggest a dependency?

Solution

  • Run mvn dependency:analyze. It shows you all dependencies that are in the POM, but that are not used in the source code. It furthermore lists transitive dependencies which you accidentally used as direct dependencies.