tonetheman's blog

how to see your dependencies in maven

If you want to see a tree of your dependencies for a maven project you can run this command

For my setup I have 2 dependencies: an older junit and a specific version of guava (from google)

mvn dependency:tree

You will get a lot of text (maven likes to talk) but eventually you will see something like this

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ myapp ---
[INFO] tone.testapp:myapp:jar:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] \- com.google.guava:guava:jar:30.1.1-jre:compile
[INFO]    +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO]    +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO]    +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO]    +- org.checkerframework:checker-qual:jar:3.8.0:compile
[INFO]    +- com.google.errorprone:error_prone_annotations:jar:2.5.1:compile
[INFO]    \- com.google.j2objc:j2objc-annotations:jar:1.3:compile

If you want to download those dependencies in one swoop you can run this command

mvn dependency:copy-dependencies

Then look in the target/dependency directory for all of the jar files.

ls target/dependency/
checker-qual-3.8.0.jar             guava-30.1.1-jre.jar        junit-3.8.1.jar
error_prone_annotations-2.5.1.jar  j2objc-annotations-1.3.jar  listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
failureaccess-1.0.1.jar            jsr305-3.0.2.jar

#java #maven