Search code examples
mavenarchiva

Issue pulling SNAPSHOT dependencies from Archiva snapshot repository


I've been setting up an Apache Archiva instance as both a proxy to Maven Central and to capture our development snapshots. I've managed to setup the proxy and I can deploy artifacts to the Archiva snapshot repository however I cannot pull artifacts from the snapshot repositories to use in other projects.

Relevant parts of pom.xml (dependant project)

<project>
  <!-- Excluded detail -->
  <dependency>
    <groupId>uk.abc</groupId>
    <artifactId>ABC</artifactId>
    <version>1.0-SNAPSHOT</version>
    <type>war</type>
  </dependency>
  <!-- Excluded detail -->
  <distributionManagement>
    <repository>
        <id>archiva.snapshots</id>
        <name>Snapshot Repository</name>
        <url>https://xxx.xxx.xxx.xxx/archiva/repository/snapshots</url>
    </repository>
  </distributionManagement>
  <!-- Excluded detail -->
</project> 

My ~/.m2/settings.xml

<settings>
  <servers>
    <server>
      <id>archiva.snapshots</id>
      <username>username</username>
      <password>xxx</password>
    </server>
    <server>
      <id>archiva.internal</id>
      <username>username</username>
      <password>xxx</password>
    </server>
  </servers>
  <mirrors>
    <mirror>
        <id>archiva.internal</id>
        <mirrorOf>central</mirrorOf>
        <url>https://xxx.xxx.xxx.xxx/archiva/repository/internal</url>
    </mirror>
    <mirror>
        <id>archiva.snapshots</id>
        <mirrorOf>snapshots</mirrorOf>
        <url>https://xxx.xxx.xxx.xxx/archiva/repository/snapshots</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
        <id>default</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
              <id>archiva.internal</id>
              <name>Archiva Managed Internal Repository</name>
              <url>https://xxx.xxx.xxx.xxx/archiva/repository/internal/</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
            </repository>
            <repository>
              <id>archiva.snapshots</id>
              <name>Archiva Managed Internal Repository</name>
              <url>https://xxx.xxx.xxx.xxx/archiva/repository/snapshots/</url>
              <releases>
                <enabled>false</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
              </snapshots>
            </repository>
        </repositories>
    </profile>
  </profiles>
</settings>

When I build the dependant project I cannot reference classes (public access).

Just to note that I can browse the snapshots repository and I know the war file is there.

Any ideas?


Solution

  • It turns out that you cannot use the "war" dependency type and expect to be able to reference the contained classes. You can however create an additional jar (create both war and jar) containing the classes:

    http://maven.apache.org/plugins/maven-war-plugin/faq.html#attached

    You can the use the type "jar" when pulling in the dependency... in my case:

    <dependency>
        <groupId>uk.abc</groupId>
        <artifactId>ABC</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>jar</type>
    </dependency>
    

    I think therefore the question is a bit misleading... the dependency was being pulled from Archiva but was not of an accessible type.