aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes duplicate maven artifacts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "duplicate maven artifacts" Watch "duplicate maven artifacts" New topic
Author

duplicate maven artifacts

Prash Negu
Ranch Hand

Joined: Apr 20, 2009
Posts: 45
Hi,

When we add multiple public repositories to settings file and if the dependency artifact is found in multiple repositories, how would maven resolves it? From which repository the required artifact would be downloaded?

Thanks,
Prashant
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15665
    
  15

Don't depend on it.

Maven requires version information for a reason. To avoid the Maven equivalent of "DLL Hell".

To assure proper operation, all copies of a given version of an artefact should be identical, regardless of what repository they reside in.

Even if you can determine a set order of lookups, you shouldn't be depending on it.


Customer surveys are for companies who didn't pay proper attention to begin with.
Prash Negu
Ranch Hand

Joined: Apr 20, 2009
Posts: 45
Sorry!! i didnt get that. Lets say I have 2 repositories X1 and X2 configured in settings file. Both have projectA artifact in them. If any local project depends on projectA, from where would maven down load projectA into local repository? is it from repository X1 or X2?

Thanks,
Prashant
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15665
    
  15

Prash Negu wrote:Sorry!! i didnt get that. Lets say I have 2 repositories X1 and X2 configured in settings file. Both have projectA artifact in them. If any local project depends on projectA, from where would maven down load projectA into local repository? is it from repository X1 or X2?

Thanks,
Prashant


Since both copies of the projectA artifact should be identical, it shouldn't matter which repository the copy was downloaded from.

And, incidentally, if a repository is unreachable or does not contain an artifact, Maven will try all the other repositories until it finds a copy or has to give up and indicate an error.
Prash Negu
Ranch Hand

Joined: Apr 20, 2009
Posts: 45
Thanks Tim. When dependency is added, it first looks into local repository and if not found will look into central repository http://repo1.maven.org/maven2/ and again if not found it will look into other remote repositories configured. Is this correct sequence? Where it is configured that http://repo1.maven.org/maven2/ is the central repository?

Thanks,
Prashant
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15665
    
  15

I have no idea about the sequence, since, as mentioned, all copies of an artefact are supposed to be identical, so whatever sequence they want to use, including round-robin, pick-at-random, or reverse alphabetical order, it's all the same in the end.

I think the location(s) of the master repositor(ies) are properties in the supplied Maven Jar file, although you can define repositories in your local Maven configuration file.

However, a lot of Maven-like services, such as CPAN and YUM feature a "best-response" repository feature, where they are set up to find the nearest/faster repository and in some cases, will dynamically adjust sequences to get best performance. Since Maven repository hits are less frequent, I don't think Maven does anything that elaborate. Yet.

Since the ibiblio master repo is about the closest high-performance Maven repository for me, I can't vouch for how clever Maven is willing to get (short of RTFM ). YMMV, especially if you're someplace like Indonesia.

In any event, it is extremely perilous to assume you know which repository an artefact will be downloaded from. If for no other reason than they can and do sometimes take them down for maintenance. For mirrored artefacts, temporary loss of a repository is not a problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: duplicate maven artifacts
 
Similar Threads
Software Development/Maven/Eclipse
Same dependency in multiple repositories
Maven Local repository Vs nexus
Maven build error
Many Maven repositories in pom.xml or settings.xml mirrors