w9n7cxx5fM8
w9n7cxx5fM8

Reputation: 49

Why is this jar on my classpath in a maven project?

I have a maven project with some dependencies, and the resulting artifact contains the dependencies as .jar files inside.

I could check the effective pom, but that does not show the actual .jar filenames / classes for the dependencies.

Is there any way to print dependency .jar names?
Is the name always ${artifactId}-${version}.jar?

Upvotes: 0

Views: 193

Answers (1)

ingyhere
ingyhere

Reputation: 13811

You can view the dependencies used in a Maven build with the Maven Dependency Plugin. To view the dependencies as a list, use:

mvn dependency:list

A better representation might be the dependency tree, though, as it clearly shows relationships between imported dependency POMs and transitive dependencies:

mvn dependency:tree

If you want to see a raw list of the JARs bundled together in your build, you can also use the dependency plugin's copy-dependencies goal:

$ mvn dependency:copy-dependencies -DoutputDirectory="\${project.builddir}/bundled-jars" 
$ ls -1 target/bundled-jars

Note that the destination is in quotes with the $ escaped so that it can use the Maven property without invoking shell substitution. You could also just write -DoutputDirectory=target/bundled-jars.

Upvotes: 1

Related Questions