Oct 07 2009
How to find project dependencies in a Maven project

It’s very useful to be able to see what is included in your class path especially when you’re trying to track down a troublesome dependency. Recently I had an issue with a JDOM dependency; however I had not defined a JDOM dependency in my pom.xml file and I couldn’t quite figure out why this dependency existed. This is where Maven’s excellent dependency plugin comes to the rescue.
In a project you may have dependencies on libraries like Log4J or Freemarker. These libraries in their turn may have dependencies on other libraries, this is also known as transitive dependencies.
Using the following Maven command we’ll be able to see a list of these dependencies:
mvn dependency:resolve
For a nice tree view of the same information use:
mvn dependency:tree
If you want to see a full dependency trail that also show you artifacts that were rejected due to conflicts or other reasons then run maven with the debug flag enabled:
mvn install -X
For more information about the Maven dependency plugin go here: http://maven.apache.org/plugins/maven-dependency-plugin/
Related posts:
- Want to use Spring 3.0 milestone release from Maven? I wanted to add the Spring 3.0 M4 milestone early...
- Maven, Log4j and javax.jms Log4j version 1.2.15 added features which has new dependencies on...
- Maven pom.xml structure I wanted to see the full Maven pom.xml structure and...
- ls full path How do you get the Unix command ls to show...