Is there a simple way to remove unused dependencies from a maven pom.xml?

thickosticko picture thickosticko · Oct 5, 2009 · Viewed 163k times · Source

I have a large Maven project with many modules and many pom.xml files. The project has changed and I suspect the pom's contain some unnecessary dependencies. Is there is a command which removes any unused dependencies from a pom?

Answer

Pascal Thivent picture Pascal Thivent · Oct 5, 2009

The Maven Dependency Plugin will help, especially the dependency:analyze goal:

dependency:analyze analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared.

Another thing that might help to do some cleanup is the Dependency Convergence report from the Maven Project Info Reports Plugin.