如何将 Apache Archiva 与 Maven 一起使用?

How to use Apache Archiva with Maven?

我已经设置了 Apache Archiva 并向其中添加了几个文件:

我觉得一切都很好。

我更新了我的 settings.xml 文件以包含配置文件:

然后我将上述依赖项添加到我的 pom.xml 文件中:

我保存它以便它重建然后砰!

拜托,看在这个世界上所有美好事物的份上,有人可以告诉我我做错了什么吗?

错误消息实际上是:

将快照更改为 "true" 并添加了屏幕截图。

在 Apache Archiva 和 Maven 之间建立连接是一个艰难的过程。

我最终在 Stack 上偶然发现了另一个 post,它对解决这个问题提供了巨大帮助。对于我的一生,我似乎再也找不到合适的信用了。如果我最终能再次找到它,我会 post 这样你就可以获得甜蜜的业力。

这是我的 settings.xml 文件:

<?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>

我知道这可能不是最有效的布局,但它最终起作用了。如果有人有任何建议可以使本文更简洁,请随时加入。

2018 年 6 月 20 日更新:

我的组织刚刚为我们的工件服务器切换到 ProGet。与 Apache Archiva 相比,它更易于使用。

ProGet的settings.xml文件如下:

<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>

那么当然不要忘记在项目的 pom 文件中引用存储库。

<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>

我希望这对研究这些东西的人有所帮助。祝你好运!