0

How do I create a simple project that fetches artifacts from my repo using maven? And where will these artifacts get saved to - my default maven repo?

I am using Apache Archiva.

Ree
  • 863
  • 2
  • 18
  • 38
  • Your question does not contain not enough information to get the correct way. Cause if you are already using a repository manager why didn't you put such information not into the question? – khmarbaise Mar 24 '14 at 14:42

1 Answers1

0

Just simply start using a repository manager like Nexus and that's it. Please configure your settings.xml file according to the following:

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>URL OF your ARCHIVA SERVER</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <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>

The artifacts which are being downloaded are first stored into the Archiva and of course on your hard drive $HOME/.m2/repository.

If you like to deploy artifact into archiva you need to configure the distributionManagement in your pom file similar like this:

 <distributionManagement>
    <repository>
      <id>releases</id>
      <name>Archiva RElease repo</name>
      <url>http://URL OF YOUR ARCHIVA/releases/</url>
    </repository>
    <snapshotRepository>
      <id>snapshots<id>
      <name>Archiva Snapshots repo</name>
      <url>http://URL OF YOUR ARCHIVA/snapshots/</url>
    </snapshotRepository>
    ...
  </distributionManagement>
  ...

To test this you can use mvn deploy to see if the artiacts are being deployed to the snapshot repository. You can change the version of your test project into 1.0 and redo a mvn deploy which will try to deploy the artifacts into the release repository.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • That's seriously not enough info! I've got archiva running on a server... What next? – Ree Mar 24 '14 at 14:13
  • Sorry, did not mean to offend u. Thanks for the help. I still don't understand how it all works though. Why does that information about the mirrors need to be in the settings XML? What part does the Pom.xml of the project play? Or is everything just set in the settings xml? And is this the settings xml on my build server? – Ree Mar 24 '14 at 15:28
  • The idea why those kind of information is in the settings.xml cause you might need authentication for the repositories to deploy something into it which results in having passwords in your settings.xml which usually is localed `$HOME/.m2/settings.xml` so it's protected. And yes you need a separate settings.xml file on your build server. If you really need to know parts are for what you need to start reading the docs about Maven like http://www.sonatype.com/resources/books and of course http://maven.apache.org (several guides etc.). Maven is not a simple toy tool. – khmarbaise Mar 24 '14 at 16:11