How to setup Archiva internal+snapshot repository for Maven?

NagyI picture NagyI · Sep 15, 2011 · Viewed 11.5k times · Source

We are trying to use Archiva as a Maven proxy for central and other external repositories and also as a snapshot storage for our artifacts which are automatically built by Hudson from SVN and installed to the snapshot repository.

I can't setup my Maven client to use the internal and snapshots repositories together. My project has some external dependencies (like log4j) which are downloaded from the Archiva internal repository correctly. Also my project has a dependency to an own project which's artifact is already built and installed to the snapshot repository. However if i try to build the project Maven can't find my snapshot artifact.

My configuration file had originally this setting:

<mirror>
  <id>company-internal</id>
  <name>Company's Archiva - Internal Repository</name>
  <url>http://www.mycompany.hu/archiva/repository/internal</url>
  <mirrorOf>*</mirrorOf>
</mirror>

and then i added the following:

<mirror>
 <id>company-snapshots</id>
 <name>Company Archiva - Snapshots Repository</name>
 <url>http://www.mycompany.hu/archiva/repository/snapshots</url>
 <mirrorOf>apache.snapshots</mirrorOf>
</mirror>

However Maven doesn't tries to look up the snaphot repository at build. What did i do wrong? By the way i don't really get the <mirrorOf> elements purpose. I've tried to replace this at internal mirror settings to central but this still doesn't fix my problem.

Answer

Raghuram picture Raghuram · Sep 15, 2011

The following configuration worked for me after some trial and error. Here I used the default archiva configuration - internal to hold releases and snapshots to hold only the internal snapshots.

Essentially unlike nexus we need two separate <mirror> and <repository> declarations - one for the normal artifacts and the other for snapshot artifacts.

<mirrors>
    <mirror>
        <id>archiva</id>
        <mirrorOf>*</mirrorOf>
        <url>http://localhost:8080/archiva/repository/internal</url>
    </mirror>
    <mirror>
        <id>snapshots</id>
        <mirrorOf>snapshots</mirrorOf>
        <url>http://localhost:8080/archiva/repository/snapshots</url>
    </mirror>
</mirrors>
<profiles>
    <profile>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
              <id>internal</id>
              <name>Archiva Managed Internal Repository</name>
              <url>http://localhost:8080/archiva/repository/internal/</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
            </repository>
            <repository>
              <id>snapshots</id>
              <name>Archiva Managed Internal Repository</name>
              <url>http://localhost:8080/archiva/repository/snapshots/</url>
              <releases>
                <enabled>false</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
              </snapshots>
            </repository>
        </repositories>
    </profile>
</profiles>