This project has retired. For details please refer to its Attic page.
Archiva Documentation – Using as a Repository

Configuring Maven 2 to use an Archiva repository

To get your local Maven 2 installation to use an Archiva proxy you need to add the repositories you require to your 'settings.xml'. This file is usually found in ${user.dir}/.m2/settings.xml (see the Settings Reference).

How you configure the settings depends on how you would like to utilise the repository. You can add the Archiva repository as an additional repository to others already declared by the project, or lock down the environment to only use the Archiva repositories (possibly proxying content from a remote repository).

Locking down to only use Archiva

If you would like Archiva to serve as the only repository used by your Maven installation, you can use the Maven mirror settings to force this behaviour.

First, you need to select the default repository to use when none is configured by adding the following to the settings.xml file:

<settings>
  <!-- omitted xml -->
  <mirrors>
    <mirror>
      <id>archiva.default</id>
      <url>http://repo.mycompany.com:8080/repository/internal/</url>
      <mirrorOf>external:*</mirrorOf>
    </mirror>
  </mirrors>
  <!-- omitted xml -->
</settings>

Note: There are other controls you can use on what is mirrored. See Maven's Guide to Mirror Settings for more information.

With this in place, all repository requests will be sent to the internal repository (which by default is configured to proxy the central repository).

If you have separate Archiva repositories that you wish to use, you can add an extra mirror declaration as needed:

    <!-- omitted xml -->
    <mirror>
      <id>archiva.apache.snapshots</id>
      <url>http://repo.mycompany.com:8080/repository/snapshots/</url>
      <mirrorOf>apache.snapshots</mirrorOf>
    </mirror>
    <!-- omitted xml -->

WARNING: Maven, as of version 2.0.8, does not properly report the correct URL in errors when a mirror is used - so although the Archiva instance is being consulted any error messages will still reflect the original URL described in the POM.

Using Archiva as an additional repository

You will need to add one entry for each repository that is setup in Archiva. If your repository contains plugins; remember to also include a <pluginRepository> setting.

  1. Create a new profile to setup your repositories
    <settings>
      <!-- omitted xml -->
      <profiles>
        <profile>
          <id>Repository Proxy</id>
          <activation>
            <activeByDefault>true</activeByDefault>
          </activation>
          <!-- ******************************************************* -->
          <!-- repositories for jar artifacts -->
          <!-- ******************************************************* -->
          <repositories>
            <repository>
              <!-- omitted xml -->
            </repository>
            <!-- omitted xml -->   
          </repositories>
          <!-- ******************************************************* -->
          <!-- repositories for maven plugins -->
          <!-- ******************************************************* -->
          <pluginRepositories>
            <pluginRepository>
              <!-- omitted xml -->
            </pluginRepository>
            <!-- omitted xml -->   
          </pluginRepositories>
        </profile>
        <!-- omitted xml -->
      </profiles>
      <!-- omitted xml -->
    </settings>
  2. Add your repository configuration to the profile

    You can copy the repository configuration from the POM Snippet on the Archiva Administration Page for a normal repository. It should look much like:

        <repository>
          <id>repository-1</id>
          <url>http://repo.mycompany.com:8080/repository/internal/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
  3. Add the necessary security configuration

    This is only necessary if the guest account does not have read access to the given repository.

    <settings>
      <!-- omitted xml -->
      <servers>
        <server>
          <id>repository-1</id>
          <username>{archiva-user}</username>
          <password>{archiva-pwd}</password>
        </server>
        <!-- omitted xml -->
      </servers>
      <!-- omitted xml -->
    </settings>