Вопрос

I simply cannot conclude, after all my reading, where and why it is necessary to change what in order to download artifacts from my archiva repository using maven.

I have archiva set up on a server and am trying to run a simple maven project that will get the artifacts in my archiva repo and download them.

Which settings.xml do I change? The one on the server or my local copy?

Does the pom.xml need to be changed at all?

Это было полезно?

Решение

Your local ~/.m2/settings.xml file (or %USERPROFILE%\.m2\setting.xml under Windows). There you can set:

<mirrors>
    <mirror>
        <id>yourrepo-id</id>
        <name>yourrepo-name</name>
        <url>http://yourrepo/archiva</url>
        <mirrorOf>*</mirrorOf>
    </mirror>
</mirrors>

Or, you could add a <profile/> which is <activeByDefault>true</activeByDefault> and add the <repositories> / <pluginRepositories> in there.

<?xml version="1.0"?>
<settings>
    <profiles>
        <profile>
            <id>add-repositories</id>
            <activation>
                <!-- Make the profile active by default -->
                <activeByDefault>true</activeByDefault>
            </activation>
            <repositories>
                <repository>
                    <!-- Each repository should have and id -->
                    <id>snapshots</id>
                    <snapshots>
                        <!-- This repository contains snapshots and Maven should always check for the latest version -->
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                    <releases>
                        <!-- No releases are stored here: only snapshots -->
                        <enabled>false</enabled>
                    </releases>
                    <!-- The URL -->
                    <url>http://yourrepo/snashots</url>
                </repository>
                <repository>
                    <!-- For releases -->
                    <id>releases</id>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <url>http://yourrepo/releases</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>snapshots</id>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <!-- The URL -->
                    <url>http://yourrepo/snashots</url>
                </pluginRepository>
                <pluginRepository>
                    <!-- For releases -->
                    <id>releases</id>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <url>http://yourrepo/releases</url>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <!-- mirrors, servers and other sections -->
</settings>

Alternatively, you could change your pom.xml and add the respective <repositories/> and/or <pluginRepositories/> section(s).

<project ...>
     <repositories>
         <repository>
             <!-- Each repository should have and id -->
             <id>snapshots</id>
             <snapshots>
                  <!-- This repository contains snapshots and Maven should always check for the latest version -->
                  <enabled>true</enabled>
                  <updatePolicy>always</updatePolicy>
             </snapshots>
             <releases>
                  <!-- No releases are stored here: only snapshots -->
                  <enabled>false</enabled>
             </releases>
             <!-- The URL -->
             <url>http://yourrepo/snashots</url>
         </repository>
         <repository>
              <!-- For releases -->
              <id>releases</id>
              <snapshots>
                  <enabled>false</enabled>
              </snapshots>
              <releases>
                  <enabled>true</enabled>
              </releases>
              <url>http://yourrepo/releases</url>
         </repository>
     </repositories>
     <pluginRepositories>
         <pluginRepository>
              <id>snapshots</id>
              <snapshots>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
              </snapshots>
              <releases>
                   <enabled>false</enabled>
              </releases>
              <!-- The URL -->
              <url>http://yourrepo/snashots</url>
         </pluginRepository>
         <pluginRepository>
              <!-- For releases -->
              <id>releases</id>
              <snapshots>
                  <enabled>false</enabled>
              </snapshots>
              <releases>
                  <enabled>true</enabled>
              </releases>
              <url>http://yourrepo/releases</url>
         </pluginRepository>
    </pluginRepositories>
</project>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top