How check if dependency is used by any of my classes and list them in Maven?

denu picture denu · Apr 27, 2012 · Viewed 7.3k times · Source

I want to do some clean up in POM.XML. How can I check which dependencies aren't used at all by my code and if one is used then how tell which one is it?

Of course I don't want to simply delete dependency and then search for errors in IDE, because that could take ages when pom has got about 80+ dependencies.

I'm using SpringSource Tools Suite version of Eclipse.

Greetz

Answer

cello picture cello · Apr 27, 2012

Have a look at the Maven Dependency Plugin. When running, it should list the dependencies that you declared but do not use, but also which intransitive dependencies you use without explicitly declaring them. Note that it you use reflection, the report may not be accurate.