Re: How maven repositories are resolved?
Thanks John for such a detailed explanation. Few doubts For release version assuming empty local repo. > - Build order this time alpha, bravo, charlie > - Alpha needs A, and Aa is downloaded as it's in central repo and that > was 1st repo in the order list When you say central repo is the first repo in the order list , how is order determined? Is it because central repo is defined before company repo in the settings.xml ? What is the "cache" you are referring to in your answer? On Thu, Jul 30, 2020 at 1:33 AM John Patrick wrote: > The answer depends on the following; > > 1) is it a release version or snapshot version. As if the release > version is in local repo then no remote repo's are checked. > 2) order your pom's are executed > > I've simplified your profiles with central repo and company repo, and > Aa, Ab and Ac are the same GAV but it's just so in the explanation > it's easier to know what A i'm talking about. > > settings > - central repo (contains Aa) > - company repo (contains Ab) > > parent-pom > - alpha > -- A > - bravo (has extra R repository like your cloudera, contains Ac) > -- A > - charlie > -- A > > For release version assuming empty local repo. > - Build order this time alpha, bravo, charlie > - Alpha needs A, and Aa is downloaded as it's in central repo and that > was 1st repo in the order list > - Bravo needs A, it sees Aa in local repo and uses it > - Charlie needs A, it sees Aa in local repo and uses it > > Same as before but maven believe build order is bravo, alpha, charlie, > i.e. you've changed an internal dependency or reorder you modules > section. > - Bravo needs A, and Ac is downloaded as it's in R repo and that was > 1st repo in the order list, which i think it's pom repo's then parent > pom's then settings file. > - Alpha needs A, it sees Ac in local repo and uses it > - Charlie needs A, it sees Ac in local repo and uses it > > Next is if A is a -SNAPSHOT dependency assuming empty local repo, Aa > is v 1-1, Ab is v1-1 and Ac is v1-1 > - Build order this time alpha, bravo, charlie > - Alpha needs A, and Aa is downloaded as it's in central repo and that > was 1st repo in the order list, but it has a cache of Ab existing > - Bravo needs A, it sees it doesn't have a cache of A from R repo, so > looks up A from R repo, and if Ac in R repo is newer it is downloaded > and used. in this case Aa is newer so Aa is used. > - Charlie needs A, it sees all repo's have caches of A, and just uses > the A in the local repo, in this case Aa is used. > > Next is if A is a -SNAPSHOT dependency assuming empty local repo, Aa > is v 1-1, Ab is v1-1 and Ac is v1-2 > - Build order this time alpha, bravo, charlie > - Alpha needs A, and Aa is downloaded as it's in central repo and that > was 1st repo in the order list, but it has a cache of Ab existing > - Bravo needs A, it sees it doesn't have a cache of A from R repo, so > looks up A from R repo, and if Ac in R repo is newer it is downloaded > and used. in this case Ac is newer so Ac is used. > - Charlie needs A, it sees all repo's have caches of A, and just uses > the A in the local repo, in this case Ac is used. > > > > As you can see it can get very messy when -SNAPSHOT's are being used > and different pom's have repo. This is my hands-on experience of trial > and error, debugging and troubleshooting of build processes. > > Hope it was helpful. > > John > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > >
Re: How maven repositories are resolved?
The answer depends on the following; 1) is it a release version or snapshot version. As if the release version is in local repo then no remote repo's are checked. 2) order your pom's are executed I've simplified your profiles with central repo and company repo, and Aa, Ab and Ac are the same GAV but it's just so in the explanation it's easier to know what A i'm talking about. settings - central repo (contains Aa) - company repo (contains Ab) parent-pom - alpha -- A - bravo (has extra R repository like your cloudera, contains Ac) -- A - charlie -- A For release version assuming empty local repo. - Build order this time alpha, bravo, charlie - Alpha needs A, and Aa is downloaded as it's in central repo and that was 1st repo in the order list - Bravo needs A, it sees Aa in local repo and uses it - Charlie needs A, it sees Aa in local repo and uses it Same as before but maven believe build order is bravo, alpha, charlie, i.e. you've changed an internal dependency or reorder you modules section. - Bravo needs A, and Ac is downloaded as it's in R repo and that was 1st repo in the order list, which i think it's pom repo's then parent pom's then settings file. - Alpha needs A, it sees Ac in local repo and uses it - Charlie needs A, it sees Ac in local repo and uses it Next is if A is a -SNAPSHOT dependency assuming empty local repo, Aa is v 1-1, Ab is v1-1 and Ac is v1-1 - Build order this time alpha, bravo, charlie - Alpha needs A, and Aa is downloaded as it's in central repo and that was 1st repo in the order list, but it has a cache of Ab existing - Bravo needs A, it sees it doesn't have a cache of A from R repo, so looks up A from R repo, and if Ac in R repo is newer it is downloaded and used. in this case Aa is newer so Aa is used. - Charlie needs A, it sees all repo's have caches of A, and just uses the A in the local repo, in this case Aa is used. Next is if A is a -SNAPSHOT dependency assuming empty local repo, Aa is v 1-1, Ab is v1-1 and Ac is v1-2 - Build order this time alpha, bravo, charlie - Alpha needs A, and Aa is downloaded as it's in central repo and that was 1st repo in the order list, but it has a cache of Ab existing - Bravo needs A, it sees it doesn't have a cache of A from R repo, so looks up A from R repo, and if Ac in R repo is newer it is downloaded and used. in this case Ac is newer so Ac is used. - Charlie needs A, it sees all repo's have caches of A, and just uses the A in the local repo, in this case Ac is used. As you can see it can get very messy when -SNAPSHOT's are being used and different pom's have repo. This is my hands-on experience of trial and error, debugging and troubleshooting of build processes. Hope it was helpful. John - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
How maven repositories are resolved?
Cross-posting from stackoverflow <https://stackoverflow.com/questions/63071141/how-maven-repositories-are-resolved> Let's say my settings.xml is defined like below http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd; xmlns="http://maven.apache.org/SETTINGS/1.1.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;> false central libs-release http://artifactory.ark.local:8080/libs-release vmware-repo VM Nexus Repo http://build-squid.eng.vm.com/nexus/content/groups/repo true false snapshots libs-snapshot http://artifactory.ark.local:8080/libs-snapshot false central plugins-release http://artifactory.ark.local:8080/plugins-release snapshots plugins-snapshot http://artifactory.ark.local:8080/plugins-snapshot artifactory artifactory In a multimodule project of the form main storage metrics config common Let's say in metrics pom if a repository is added. cloudera https://repository.cloudera.com/artifactory/cloudera-repos/ 1. If a dependency is defined in A which is present in both cloudera repo and local nexus repo how maven will resolve the repository? Will, it first try to download from cloudera repo and if there is some problem then it will go in local nexus repo or it will check only in cloudera repo and if it is not present it will give error without trying from local nexus repo? 2. Does the answer to the above question change based on if A is defined as a dependency in metric or some other pom where the repository is not defined? Maven Version - 3.6.3