You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/10/07 12:28:27 UTC

[maven-site] branch master updated: [MNG-6994] clarify remote repository order

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-site.git


The following commit(s) were added to refs/heads/master by this push:
     new 0fed2cc  [MNG-6994] clarify remote repository order
0fed2cc is described below

commit 0fed2ccf328a672887c7da29cfa139d6991ad866
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sat Oct 3 20:07:42 2020 +0200

    [MNG-6994] clarify remote repository order
    
    clarify profile order
    Closes #205
---
 .../introduction/introduction-to-profiles.apt      | 50 ++++++++++++++++++++++
 .../introduction/introduction-to-repositories.apt  |  2 +-
 content/apt/guides/mini/guide-mirror-settings.apt  |  2 +-
 .../guides/mini/guide-multiple-repositories.apt    | 20 +++++++--
 4 files changed, 69 insertions(+), 5 deletions(-)

diff --git a/content/apt/guides/introduction/introduction-to-profiles.apt b/content/apt/guides/introduction/introduction-to-profiles.apt
index 3b2b7d2..a7bd1eb 100644
--- a/content/apt/guides/introduction/introduction-to-profiles.apt
+++ b/content/apt/guides/introduction/introduction-to-profiles.apt
@@ -403,6 +403,56 @@ mvn groupId:artifactId:goal -P !profile-1,!profile-2
   One of the goals in Maven 2 is to consolidate all the information needed to
   run a build into a single file, or file hierarchy which is the POM.
 
+* Profile Order
+
+All profile elements in a POM from active profiles overwrite the global elements with the same name of the POM or extend those in case of collections.
+In case multiple profiles are active in the same POM or external file, the ones which are defined <<later>> take precedence over the ones defined <<earlier>> (independent of their profile id and activation order).
+
+Example:
+
++---+
+<project>
+  ...
+  <repositories>
+    <repository>
+      <id>global-repo</id>
+      ...
+    </repository>
+  </repositories>
+  ...
+  <profiles>
+    <profile>
+      <id>profile-1</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <repositories>
+        <repository>
+          <id>profile-1-repo</id>
+          ...
+        </repository>
+      </repositories>
+    </profile>
+    <profile>
+      <id>profile-2</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <repositories>
+        <repository>
+          <id>profile-2-repo</id>
+          ...
+        </repository>
+      </repositories>
+    </profile>
+    ...
+  </profiles>
+  ...
+</project>
++---+
+
+This leads to the repository list: <<<profile-2-repo, profile-1-repo, global-repo>>>.
+
 * Profile Pitfalls
 
   We've already mentioned the fact that adding profiles to your build has the
diff --git a/content/apt/guides/introduction/introduction-to-repositories.apt b/content/apt/guides/introduction/introduction-to-repositories.apt
index 26113d8..ed80832 100644
--- a/content/apt/guides/introduction/introduction-to-repositories.apt
+++ b/content/apt/guides/introduction/introduction-to-repositories.apt
@@ -70,7 +70,7 @@ Introduction to Repositories
  To override this, you need to specify a <<<mirror>>> as shown in {{{../mini/guide-mirror-settings.html}Using Mirrors for Repositories}}.
 
  You can set this in your <<<settings.xml>>> file to globally use a certain mirror. However,
- it is common for a project to customise the repository in its <<<pom.xml>>>
+ it is common for a project to {{{../mini/guide-multiple-repositories.html}customise the repository in its <<<pom.xml>>>}}
  and that your setting will take precedence. If dependencies are not being found, check that you
  have not overridden the remote repository.
 
diff --git a/content/apt/guides/mini/guide-mirror-settings.apt b/content/apt/guides/mini/guide-mirror-settings.apt
index 5e4b629..effe3e2 100644
--- a/content/apt/guides/mini/guide-mirror-settings.apt
+++ b/content/apt/guides/mini/guide-mirror-settings.apt
@@ -32,7 +32,7 @@ Using Mirrors for Repositories
 
  With {{{/guides/introduction/introduction-to-repositories.html}Repositories}} you specify from
  which locations you want to <download> certain artifacts, such as dependencies and maven-plugins.
- Repositories can be declared inside a project, which means that if you have your own custom repositories, those sharing
+ Repositories can be {{{../mini/guide-multiple-repositories.html}declared inside a project}}, which means that if you have your own custom repositories, those sharing
  your project easily get the right settings out of the box. However, you may want to use an alternative mirror
  for a particular repository without changing the project files.
 
diff --git a/content/apt/guides/mini/guide-multiple-repositories.apt b/content/apt/guides/mini/guide-multiple-repositories.apt
index 663f22e..f9e29c5 100644
--- a/content/apt/guides/mini/guide-multiple-repositories.apt
+++ b/content/apt/guides/mini/guide-multiple-repositories.apt
@@ -29,7 +29,7 @@
 Setting up Multiple Repositories
 
  There are two different ways that you can specify the use of multiple repositories. The first
- way is to specify in a POM which repositories you want to use:
+ way is to specify in a POM which repositories you want to use. That is supported both inside and outside of build profiles:
 
 +----+
 
@@ -55,8 +55,10 @@ Setting up Multiple Repositories
  <<NOTE:>> You will also get the standard set of repositories as defined in the 
  {{{../introduction/introduction-to-the-pom.html#Super_POM}Super POM}}.
 
- The other way you can specify the use of multiple repositories by creating a profile in
- your <<<$\{user.home\}/.m2/settings.xml>>> file like the following:
+
+
+ The other way you can specify multiple repositories is by creating a profile in the
+ <<<$\{user.home\}/.m2/settings.xml>>> or <<<$\{maven.home\}/conf/settings.xml>>> file like the following:
 
 +----+
 
@@ -102,3 +104,15 @@ mvn -Pmyprofile ...
  activate multiple profiles simultaneously.
  
  <<Note>>: The settings descriptor documentation can be found on the {{{../../maven-settings/settings.html}Maven Local Settings Model Website}}.
+ 
+ ** Repository Order
+
+Remote repository URLs are queried in the following order for artifacts until one returns a valid result:
+
+[[1]] Global <<<settings.xml>>>
+[[1]] User <<<settings.xml>>>
+[[1]] Local POM
+[[1]] Parent POMs, recursively
+[[1]] Super POM
+
+For each of these locations, the repositories within the profiles are queried first in the order outlined at {{{../introduction/introduction-to-profiles.html}Introduction to build profiles}}.