gri*_*gon 5 nexus maven-3 maven
我已被添加到另一个工作团队。两个团队都使用自己的 Nexus 服务器,并为我提供了自己的设置文件,因此目前我必须做大量的工作来确保我使用正确的 settings.xml 文件来构建项目。有没有好的方法来合并这些文件?我一直在浏览 Maven 文档,但感到非常困惑。设置文件如下(已删除识别信息)
团队 1 设置文件
<settings>
<mirrors>
<mirror>
<id>Nexus</id>
<name>Company Nexus Public Mirror</name>
<url>http://build.company.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<servers>
<server>
<id>snapshots</id>
<username>deployment</username>
<password>password1</password>
</server>
<server>
<id>releases</id>
<username>deployment</username>
<password>password2</password>
</server>
</servers>
<activeProfiles>
<activeProfile>jenkins</activeProfile>
</activeProfiles>
</settings>
Run Code Online (Sandbox Code Playgroud)
团队 2 设置文件
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://domain.company.com:8081/nexus/content/groups/public</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>
<servers>
<server>
<id>snapshots</id>
<username>deployment</username>
<password>password3</password>
</server>
<server>
<id>releases</id>
<username>deployment</username>
<password>password4</password>
</server>
</servers>
</settings>
Run Code Online (Sandbox Code Playgroud)
我尝试合并这些<mirrors>部分,以便列出两个镜像,但只构建一个团队的代码。我也不明白服务器 ID 是如何工作的。我将为不同的服务器使用不同的用户名/密码组合。我认为服务器 ID 应该与镜像部分中的 ID 匹配,但显然情况并非如此。但如果不是这样,maven 如何知道要使用哪个快照或发布服务器?
根据我的经验,实际上只有一种可行且简单的解决方案,并且它不包括合并设置文件。
必要时切换设置文件。只需将这两个文件放在某处,并使用一个命令行脚本来切换它们(从模板文件复制到 settings.xml 之上)。或者..有不同的命令传入-s..问题是你这不能很好地与IDE使用集成。
如果不同服务器的 id 值使用不同的名称,您还可以在计算机上本地安装 Nexus Repository Manager 并代理两个外部服务器。但在您的场景中,这是行不通的,因为使用了不同服务器的重叠 id 值。这肯定是因为双方团队对 id 的用途存在误解。
| 归档时间: |
|
| 查看次数: |
2780 次 |
| 最近记录: |