This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Same dependency in multiple repositories Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Same dependency in multiple repositories" Watch "Same dependency in multiple repositories" New topic

Same dependency in multiple repositories

Shah Jenish

Joined: Feb 19, 2009
Posts: 13
Hi All,

We have a pom.xml file with few dependencies belongs to two repositories. But there is one dependency jar which is part of both the repositories and at the same path only at both the place.

Is there any way where I can mention in Pom.xml that particular dependency should be taken from a particular repository only?

Peter Johnson

Joined: May 14, 2008
Posts: 5812

I would hope that they are both the same! Especially if the artifact name is the same.

I think that the order in which you specific the repositories in your settings.xml file (or on your POM) is the order in which Maven looks for the artfiact.

JBoss In Action
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960

This is one of the key features of Maven: that it produces a uniform product from uniform parts. If your 2 different copies of that particular dependency are not identical, then you've lost that guarantee of a uniform product.

I have one project that references something like 5 different repositories. There's a lot of overlap, since several of them allow dual use as your one-and-only repo as well as adding their particular product goodness. If it was a scramble between all these repositories for copies of dependencies, it would be a nightmare of the worst kind. As it is, I don't have to worry about which repo a given dependency gets pulled from.

Customer surveys are for companies who didn't pay proper attention to begin with.
I agree. Here's the link:
subject: Same dependency in multiple repositories
Similar Threads
Dependency Management vs Dependencies
Richfaces + Spring + Maven Setup help
Cannot find parent error while "mvn compile"
Tomcat - The requested resource is not available
Maven - Remove unused jars from repository