Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

duplicate maven artifacts

 
Prash Negu
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prash Negu
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic