Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out why a jar was included by Maven?

Tags:

We're using Maven 3 with IntelliJ for our IDE. After a compile we get a bunch of spring 2.0 stuff being included in the External Libraries. If I look through Maven Projects dependencies in Intellij I don't see anyone with a dependency on spring 2.0 so I suspect it's something we're depending on which depends on it.

My question is how would I track this down? I tried doing a mvn dependency:tree -Dverbose -Dincludes=spring-aop and even -Dincludes=spring but get no results when ran from the root or a sub module directory that I know is using spring.

like image 285
Shane Courtrille Avatar asked Jan 04 '11 19:01

Shane Courtrille


People also ask

Where do Maven dependencies come from?

In Maven, you declare your project's dependencies in your pom. xml file. Once you've added the dependency into your POM, Maven does the rest. At build time, it downloads the dependency, and makes it available to the build process.

How do you determine the dependency of a jar?

jar file. Use the -verbose:class option to find class-level dependencies or use the -v or -verbose option to include dependencies from the same JAR file.

Where is the jar file created by Maven?

In your project's target directory you'll see the generated jar file which is named like: 'core-1.0-SNAPSHOT. jar'. The resulting 'jar' file contains the compiled java class files as well as the files from src/main/resources.

How do you analyze a dependency tree in Maven?

A project's dependency tree can be filtered to locate specific dependencies. For example, to find out why Velocity is being used by the Maven Dependency Plugin, we can execute the following in the project's directory: mvn dependency:tree -Dincludes=velocity:velocity.


1 Answers

It looks like the pattern passed to -Dincludes is incorrect.

From the documentation of Maven Dependency Plugin, the syntax of -Dincludes is defined by StrictPatternIncludesArtifactFilter. From the javadoc of AbstractStrictPatternArtifactFilter from which this is subclassed,

The artifact pattern syntax is of the form:

[groupId]:[artifactId]:[type]:[version]

Where each pattern segment is optional and supports full and partial * wildcards. An empty pattern segment is treated as an implicit wildcard.

For example, org.apache.* would match all artifacts whose group id started with org.apache., and :::*-SNAPSHOT would match all snapshot artifacts.

Maybe you should run mvn dependency:tree without -Dincludes and see if it shows up the spring 2.0 related dependency. Alternately, specify the appropriate pattern for -Dincludes.

like image 51
Raghuram Avatar answered Oct 19 '22 17:10

Raghuram