1

I have a build box on which is installed:

  • Maven
  • Bamboo
  • Archiva

I have configured Bamboo to grab my Maven project from a remote Git source and then build it with the goals 'clean install'.

I have configured Archiva with two repos:

  1. mirror - a mirror of central
  2. dev - repo for my artifacts

I have made the following changes to Maven settings.xml:

# Define local repo - this is the same location as i have set up for the Archiva 'dev' repo.
<localRepository>/opt/maven-repo/dev</localRepository>

# Define the Archiva mirror i set up
<mirror>
  <id>mirror</id>
  <url>http://localhost:8080/repository/mirror/</url>
  <mirrorOf>external:*</mirrorOf>
</mirror>

When I execute the build Maven grabs everything external via the mirror and then adds the built artifact to dev, along with the other jars it grabbed from mirror. So i now have some duplicate jars...

\repo\mirror\junit\junit \repo\mirror\classworlds\classworlds \repo\dev\junit\junit \repo\dev\classworlds\classworlds \repo\dev\me\myartifact

My question is, is the correct approach? Really I want to keep 'dev' with just my artifacts and mirror with everything from central - i don't want duplicates.

Should I be using the LocalRepository config in settings.xml or should I be using 'mvn deploy' to put the artifact in my Archiva repository by a different method?

Could someone clarify the different use cases for a local and remote repository?

Finally, how should I be defining my POM? Currently, I have just defined

<distributionManagement>
    <repository>
        <id>dev</id>
        <url>file:///repo/dev</url>
    </repository>
</distributionManagement>

Should i be adding in my mirror?

wimnat
  • 1,129
  • 1
  • 13
  • 27

1 Answers1

0

To put artifacts in your repository manager you should use the default which is maven-deploy-plugin which can be controlled by distributionManagement. The target where to put those things is controlled by defining the distributionManagement.

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
  ...
  <distributionManagement>
    <repository>
      <id>releases</id>
      <name>Release</name>
      <url>http://urlArchiva/releases/</url>
    </repository>
    <snapshotRepository>
      <id>snapshots</id>
      <name>Snapshots</name>
      <url>http://urlArchiva/snapshots/</url>
    </snapshotRepository>
    ...
  </distributionManagement>
  ...
</project>

The repositories which are used to consume artifacts from is defined in the settings.xml

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://serverUrlArchiva/public/</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

On Bamboo you should be able to control which settings.xml is used to have an local repository per build which makes build independent from each other.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235