How to use Apache Archiva with Maven?

3k views Asked by At

I have set up Apache Archiva and added a couple of files to it:

enter image description here

enter image description here

Everything looks good, I think.

I have updated my settings.xml file to include the profile:

enter image description here

I then add the above mentioned dependency to my pom.xml file:

enter image description here

I save it so that it rebuilds and then bam!

enter image description here

Please, for the love of all that is good in this world can someone tell me what I'm not doing correctly?

The error message actually reads:

enter image description here

Changed snapshots to "true" and adding screenshot.

enter image description here

1

There are 1 answers

4
Anton On BEST ANSWER

Making the connection between Apache Archiva and Maven was a difficult slog.

I eventually stumbled across another post here on Stack that was a tremendious help in figuring this out. For the life of me I can't seem to find again to give proper credit. If I eventually find it again I will post so you can get that sweet sweet karma.

Here is my settings.xml file:

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<proxies>
    <proxy>
        <id>optional</id>
        <active>true</active>
        <protocol>http</protocol>
        <host>myproxyserver.name.org</host>
        <port>8080</port>
        <nonProxyHosts>localhost|myserver</nonProxyHosts>
     </proxy>
</proxies>

<servers>
    <server>
        <id>my.snapshots</id>
    </server>
</servers>

<mirrors>
    <mirror>
        <id>Central</id>
        <url>http://repo.maven.apache.org/maven2</url>
        <mirrorOf>my.snapshots</mirrorOf>
    </mirror>
    <mirror>
        <id>archiva.default</id>
        <mirrorOf>Central</mirrorOf>
        <url>http://myserver:8080/repository/internal/</url>
    </mirror>
    <mirror>
        <id>my.snapshots</id>
        <mirrorOf>Central</mirrorOf>
        <url>http://myserver:8080/repository/snapshots</url>
    </mirror>
</mirrors>

<profiles>
    <profile>
        <id>internal</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <id>archiva.internal</id>
                <name>Archiva Managed Internal Repository</name>
                <url>http://myserver:8080/repository/internal/</url>
                <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
                <snapshots><enabled>false</enabled></snapshots>
            </repository>
            <repository>
                <id>archiva.snapshots</id>
                <name>Archiva Managed Internal Repository</name>
                <url>http://myserver:8080/repository/snapshots/</url>
                <releases><enabled>false</enabled></releases>
                <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
            </repository>
        </repositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>internal</activeProfile>
</activeProfiles>

I understand that this may not be the most efficient layout but it finally worked. If anyone has any recommendations to make this more concise please feel free to chime in.

Update on June 20, 2018:

My organization just switched to ProGet for our artifact server. It's significantly easier to use compared to Apache Archiva.

The settings.xml file for ProGet is as follows:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <proxies>
        <proxy>
            <id>optional</id>
            <active>true</active>
            <protocol>http</protocol>
            <host>mycompany.ourproxy.org</host>
            <port>8080</port>
            <nonProxyHosts>localhost|servernamewhereProGetlives</nonProxyHosts>
        </proxy>
    </proxies>

    <mirrors>
        <mirror>
            <id>ProGet</id>
            <url>http://servernamewhereProGetlives/maven/</url>
            <mirrorOf>*,!central</mirrorOf>
        </mirror>
    </mirrors>
</settings>

Then of course don't forget to reference the repository in your projects' pom file.

<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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>myproject</groupId>
    <artifactId>something</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <repositories>
        <repository>
            <id>ProGet</id>
            <name>My Site - ProGet</name>
            <url>https://myserver.org/feeds</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <artifactId>something</artifactId>
            <groupId>something-something-whatever</groupId>
            <version>1.1.3</version>
        </dependency>
    </dependencies>
</project>

I hope this helps whoever is researching this stuff. Good luck!