在 Apache Archiva 和 Maven 之间建立连接是一项艰巨的任务。
我最终偶然发现了 Stack 上的另一篇文章,它对解决这个问题很有帮助。对于我的一生,我似乎无法再次给予适当的信任。如果我最终再次找到它,我会发布,这样你就可以获得甜蜜的业力。
这是我的 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>
我希望这对正在研究这些东西的人有所帮助。祝你好运!