Using Mirrors for Repositories

Repositories are 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.

Some reasons to use a mirror are:

  • There is a synchronized mirror on the internet that is geographically closer and faster
  • You want to replace a particular repository with your own internal repository which you have greater control over
  • You want to run maven-proxy to provide a local cache to a mirror and need to use it's URL instead

To configure a mirror of a given repository, you provide it in your settings file ($HOME/.m2/settings.xml), giving the new repository its own id and url , and specify the mirrorOf setting that is the ID of the repository you are using a mirror of. For example, the ID of the main Maven repository included by default is central , so to use the mirror at ibiblio , you would configure the following:

<settings>
  .
  <mirrors>
    <mirror>
      <id>ibiblio.org</id>
      <name>ibiblio Mirror of http://repo1.maven.org/maven2/</name>
      <url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  .
</settings>

The settings descriptor documentation can be found on the Maven Local Settings Model Website .

Note : The official Maven 2 repository is at http://repo1.maven.org/maven2 , the following mirrors may not have the same contents and we don't support them in any way, although we try to keep info in this page accurate.

As of today, the following mirrors are available:

<settings>
  <mirrors>
    <mirror>
      <id>ibiblio.org</id>
      <url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- United States, North Carolina -->
    </mirror>
    <mirror>
      <id>lsu.edu</id>
      <url>http://ibiblio.lsu.edu/main/pub/packages/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- United States, Louisiana -->
     </mirror>
    <mirror>
      <id>sateh.com</id>
      <url>http://maven.sateh.com/repository</url>
      <mirrorOf>central</mirrorOf>
      <!-- The Netherlands, Amsterdam -->
    </mirror>
    <mirror>
      <id>dotsrc.org</id>
      <url>http://mirrors.dotsrc.org/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- Denmark -->
    </mirror>
    <mirror>
      <id>sunsite.dk</id>
      <url>http://mirrors.sunsite.dk/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- Denmark -->
    </mirror>
    <mirror>
      <id>skynet.be</id>
      <url>http://maven2.mirrors.skynet.be/pub/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- Belgium -->
    </mirror>
    <mirror>
      <id>cica.es</id>
      <url>http://ftp.cica.es/mirrors/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- Spain, Sevilla -->
    </mirror>
    <mirror>
      <id>redv.com</id>
      <url>http://mirrors.redv.com/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- Shanghai, China -->
    </mirror>

    <!-- these just point to ibiblio.org -->
    <mirror>
      <id>ibiblio.net</id>
      <url>http://www.ibiblio.net/pub/packages/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- United States, North Carolina -->
    </mirror>
    <mirror>
      <id>ggi-project.org</id>
      <url>http://ftp.ggi-project.org/pub/packages/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- The Netherlands, Amsterdam -->
    </mirror>
  </mirrors>
</settings>

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 * .

Note: This feature is only available in Maven 2.0.5+.

<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>

Advanced Mirror specification

A single mirror can handle multiple repositories when used in conjunction with a repository manager.

The syntax as of Maven 2.0.9:

  • * matches all repo ids.
  • external:* matches all repos except those using localhost or file based repositories. This is used in conjunction with a repository manager when you want to exclude redirecting repositories that are defined for Integration Testing.
  • multiple repos may be specified using , as the delimiter
  • ! may be used in conjunction with one of the above wildcards to exclude a repo id.

    The order is not important from left to right as the wildcards defer to further processing and explicit includes or excludes stop the processing. Additionally, the mirror list will now be ordered using a LinkedHashMap instead of HashMap such that the user may influence match order by changing the order of the definitions in the settings.xml

    Examples:

  • * = everything
  • external:* = everything not on the localhost and not file based.
  • repo,repo1 = repo or repo1
  • *,!repo1 = everything except repo1

    Note: This feature is only available in Maven 2.0.9+.

    <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>external:*,!foo</mirrorOf>
        </mirror>
        <mirror>
          <id>foo-repository</id>
          <name>Foo</name>
          <url>http://repo.mycompany.com/foo</url>
          <mirrorOf>foo</mirrorOf>
        </mirror>
      </mirrors>
      .
    </settings>

FTP access

The repository is available through FTP at ftp://mirrors.ibiblio.org/pub/packages/maven2

Creating your own mirror

The central repository requires around 16 GB and growing, and it's updated every 4 hours.

You can mirror the central repository using rsync from several mirrors, choose one

rsync -v -t -l -r mirrors.ibiblio.org::maven2 /your/local/path
rsync -v -t -l -r rsync://rsync.cica.es/maven2 /your/local/path

If you want to become an official mirror, email us to dev@maven.apache.org with your location and we'll add you to the list of mirrors.