如何配置 Maven 项目以将快照和发布部署到 Nexus? [英] How to configure maven project to deploy both snapshot and releases to Nexus?

查看:42
本文介绍了如何配置 Maven 项目以将快照和发布部署到 Nexus?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何配置 Maven 项目以将快照和发布都部署到 Nexus?

How to configure maven project to deploy both snapshot and releases to Nexus?

<distributionManagement>
    <repository>
        <id>InternalReleases</id>
        <name>Internal Releases</name>
        <url>http://192.168.16.232:8081/nexus/content/repositories/releases/</url>
    </repository>
    <repository>
        <id>InternalSnapshots</id>
        <name>Internal Snapshots</name>
        <url>http://192.168.16.232:8081/nexus/content/repositories/snapshots/</url>
    </repository>
</distributionManagement>

此配置会在 Eclipse 3.8 和 m2e 1.2 中产生错误

This configuration creates error in Eclipse 3.8 with m2e 1.2

Project build error: Non-parseable POM D:WorkspacesWParentpom.xml: Duplicated tag: 'repository' (position: START_TAG 
 seen ...

当 pom 的版本带有 -SNAPSHOT 后缀时,我希望将工件部署到 InternalSnapshots 存储库,并在它是 RELEASE 时部署到 InternalReleases 存储库.这应该使用相同的 pom.xml 文件并执行相同的 mvn deploy 命令.

I want the artifact deployed to the InternalSnapshots repository when the pom's version is suffixed with -SNAPSHOT and deployed to the InternalReleases repository when it is RELEASE. This should happen using the same pom.xml file and executing the same mvn deploy command.

推荐答案

您需要区分发布和快照存储库. 只允许一个 和一个 子项.

You need to distinguish between the releases and snapshots repository. <distributionManagement> only allows one <repository> and one <snapshotRepository> child.

http://maven.apache.org/pom.html#Distribution_Management

这篇关于如何配置 Maven 项目以将快照和发布部署到 Nexus?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆