gpt4 book ai didi

maven - 当通过存储库访问父 pom 时,将忽略父 pom 中的

转载 作者:行者123 更新时间:2023-12-05 07:52:10 25 4
gpt4 key购买 nike

我有公司的 maven 存储库。我有 super 公司pom.xml与部分 <repository><pluginRepository>指向公司 repo 协议(protocol)。公司super pom是分离神器。

我开发我的 maven 项目。父 pom 是公司 super pom。为了在干净的环境中通过构建,我需要再次定义 <repository>在我的项目主页中,因为 Maven 必须知道在哪里可以找到父 pom(参见 Catch-22)

我很不高兴在我的项目中再次定义公司存储库,但我接受了。

在我的项目中,我使用公司插件。问题是 Maven 找不到公司插件。这很奇怪,因为 maven 使用 <pluginRepository> 找到了 super pom但不使用插件存储库来查找插件!所以我必须再次定义 <pluginRepository>

super pom:

<repositories>
<repository>
<id>company-repo</id>
<url>http://mycompany.com/repo</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>company-repo</id>
<url>http://mycompany.com/repo</url>
</pluginRepository>
</pluginRepositories>

我的项目pom:

<!-- required to find company super pom - unhappy but accepted-->
<repositories>
<repository>
<id>company-repo</id>
<url>http://mycompany.com/repo</url>
</repository>
</repositories>
<!-- required to find company plugin - unhappy and hard to accept-->
<pluginRepositories>
<pluginRepository>
<id>company-repo</id>
<url>http://mycompany.com/repo</url>
</pluginRepository>
</pluginRepositories>

问题:是否可以避免在每个 Maven 项目中重复配置插件仓库?也许我应该改变我的设计/配置/其他什么?

有什么有趣的,<pluginRepositories>如果通过相对路径而不是通过存储库访问 super pom,则不需要。

maven 3.3.3

更新:

如果我删除 <pluginRepositories>从我的项目 pom 然后 effective-pom 不会将 company-repo 显示为插件存储库。我希望。

最佳答案

最简单的是 setup your settings.xml file like this:

<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost: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>
</settings>

使用存储库管理器让生活更轻松...除此之外,您当然可以使用 single pom which could be made .但是对于开发人员来说,使用父级不能改变,你不能改变 CI 解决方案(比如 Jenkins)来配置他们适当的 settings.xml

关于maven - 当通过存储库访问父 pom 时,将忽略父 pom 中的 <pluginRepository>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34063476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com