raven-king
raven-king

Reputation: 1550

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?

Upvotes: 0

Views: 521

Answers (2)

raven-king
raven-king

Reputation: 1550

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.

Upvotes: 1

Hilikus
Hilikus

Reputation: 10331

You are probably not activating the profile correctly

before the profile in settings.xml put something like

<activeProfiles>
    <activeProfile>default</activeProfile>
</activeProfiles>

Remember this about activeByDefault

This profile will automatically be active for all builds unless another profile in the same POM is activated using one of the previously described methods. All profiles that are active by default are automatically deactivated when a profile in the POM is activated on the command line or through its activation config.

if you want to confirm if this is the issue, look at the active profiles by running help:active-profiles

Upvotes: 0

Related Questions