Gep
Gep

Reputation: 928

How do I know which project is requesting a specific jar from Maven

I'm using Eclipse and recently upgraded all my projects to use the latest version of a library. However in the Maven repository I can still see the old version of the library. I've deleted manually the old library from the Maven repository, but it keeps coming back. I am sure all the projects in Eclipse point to the new version: I've checked all my pom.xml, I've used the "Dependency Hierarchy" tool, etc.

Is there a way to know which project is telling Maven to download the old version of the library?

Many thanks!

Upvotes: 0

Views: 402

Answers (4)

Gerold Broser
Gerold Broser

Reputation: 14762

Re: "and I have many". Perform the following in the topmost directory:

 find . -name "pom.xml" -type f -exec mvn dependency:tree -f {} ';' | grep '^\[.*\] [-+\\\|].*'

Syntax details may vary from Bash to Bash.

Hint: Try it in a bottommost project directory first to ensure that it runs properly as intended. Since you have many projects it may take a while to finish and to recognize possible errors only then.

Upvotes: 1

Gep
Gep

Reputation: 928

Thanks guys, appreciated, but it certainly is not an easy way. It looks like you have to do project by project (and I have many). Plus most of my pom reference poms in other folders and it's not able to process that either.

Upvotes: 0

fmucar
fmucar

Reputation: 14558

You can use below command to get a tree of all dependencies and then find out where the specific artifact is coming from.

You can pipe with grep to show only the related ones if you you are on linux/unix based os.

mvn dependency:tree

Upvotes: 0

M A
M A

Reputation: 72864

You can use the Maven dependency plugin's tree goal:

mvn dependency:tree

and filter using the includes option which uses the pattern [groupId]:[artifactId]:[type]:[version].

Upvotes: 1

Related Questions