Search code examples
maven

Difference between using a single repository and a single mirror


The maven documentation says:

http://maven.apache.org/guides/mini/guide-mirror-settings.html

Using A Single Repository. You can force Maven to use a single repository by having it mirror all repository requests. The repository must contain all of the desired artifacts, or be able to proxy the requests to other repositories. This setting is most useful when using an internal company repository with the Maven Repository Manager to proxy external requests.

To achieve this, set mirrorOf to *.

<settings>
  ...
  <mirrors>
    <mirror>
      <id>internal-repository</id>
      <name>Maven Repository Manager running on repo.mycompany.com</name>
      <url>http://repo.mycompany.com/proxy</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>

I don't understand this paragraph.

Shouldn't it be something like this?

Using A Single Mirror You can force Maven to use a single mirror by having it mirror all repository requests. The mirror must contain all of the desired artifacts for all the repositories, or be able to proxy the requests to other repositories. This setting is most useful when using an internal company repository with the Maven Repository Manager to proxy external requests. To achieve this, set mirrorOf to *.

 <settings>
   ...
   <mirrors>
     <mirror>
       <id>internal-mirror</id>
       <name>Maven Mirror Manager running on mirror.mycompany.com</name>
       <url>http://mirror.mycompany.com/proxy</url>
       <mirrorOf>*</mirrorOf>
     </mirror>
   </mirrors>
   ...
 </settings>

Where is my miss-understanding?

I mean, <mirror><id>internal-repository</id>... seems just wrong to me.


Solution

  • Mirror means a repository that is used as a passerelle/proxy to an other repository. When using a repository manager like Nexus, Artiafactory, Archiva... you dispose of one local entreprise repository wich proxifies remotes ones. So there is no need to declare too many repositories in your pom or setting.xml. Using Just one mirror which redirect all requests to the repository manager you have will be sufficient. That is the meaning of the documentation.