Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven multiple repositories -- how exactly does maven decide which repo to fetch which artifact?

I have a project that needs to fetch artifacts from two different repos. And even the artifacts inside the repos have dependencies to one another. For example, my project might depend on artifact A (in repo 1), which depends on artifact B( in repo 2), which again depends on artifact C (in repo 1 again).

I am having a lot of trouble configuring my settings.xml to make it work (For example mvn always tries to go to repo 1 for artifact B, which is wrong). Anybody got a clue how exaclty this is decided in maven?

like image 530
CuriousMind Avatar asked May 14 '15 16:05

CuriousMind


1 Answers

All repositories are searched in order.

The number one reason why this does not happen are <mirror>s. Mirrors override repository definitions. If you, for example, define a mirror with <mirrorOf>*</mirrorOf> it will take all the requests and your other repository definitions just don't matter any more.

The number two reason is problems with one of the repositories. A repository which does not contain an artifact is expected to answer with 404. If it instead returns some gibberish or a 500 error or anything else, this might break the resolution.

like image 193
J Fabian Meier Avatar answered Nov 13 '22 16:11

J Fabian Meier