使用 maven 3.0.5 发布快照到 nexus [英] Release a snapshot to nexus using maven 3.0.5

查看:80
本文介绍了使用 maven 3.0.5 发布快照到 nexus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法发布我使用 maven 构建的工件的快照版本到 nexus.我的工件的版本是 1.0.0-SNAPSHOT.

I am unable to release a snapshot version of an artifact which I build using maven to nexus. The version of my artifact states 1.0.0-SNAPSHOT.

我可以毫无问题地执行 mvn clean install.但是当我尝试使用 mvn deploy 进行部署时,出现以下错误:

I can execute mvn clean install without an issue. But when I try to deploy using mvn deploy , I get the following error :

Return code is: 400, ReasonPhrase: Repository version policy: RELEASE does not allow version: 1.0.0-20161019.214318-1. -> [Help 1]

据我所知,maven3 在我要部署的工件上添加了时间戳而不是 SNAPSHOT 后缀.maven3 不支持 maven 的 标签.我需要采用什么方法来使用 mvn deploy 命令部署这些工件.

According to what I was able to find out was that maven3 adds the timestamp instead of the SNAPSHOT suffix on the artifact that I want to deploy. The <uniqueVersion> tag of maven is not supported in maven3. What is the approach that I need to take to deploy these artifacts using mvn deploy command.

更新:pom.xml

   <distributionManagement>
    <repository>
      <id>my-nexus-snapshots</id>
      <name>Internal Snapshot Releases</name>
      <url>http://localhost:9999/repository/maven-snapshots/</url>
    </repository>
    <snapshotRepository>
      <id>my-nexus-releases</id>
      <name>Internal Releases</name>
      <url>http://localhost:9999/repository/maven-releases/</url>
    </snapshotRepository>
  </distributionManagement>

settings.xml

settings.xml

    <server>
        <id>my-nexus-snapshots</id>
        <username>user</username>
        <password>user123</password>
    </server>
    <server>
        <id>my-nexus-releases</id>
        <username>user</username>
        <password>user123</password>
    </server>

推荐答案

通常,您的 nexus 具有单独的存储库快照"和发布".SNAPSHOT 版本部署到前者,非 SNAPSHOT 版本部署到后者.对于部署,这些存储库必须由您指定.您可以通过将 distributionManagement 部分添加到您的 pom 中来做到这一点.您可以在那里为两个目标定义特定的目标.

Usually, your nexus has separate repositories "snapshots" and "releases". SNAPSHOT versions are deployed to the former, non-SNAPSHOT versions to the latter. For deployment, these repositories have to be specified by you. You can do this by adding the distributionManagement section to your pom. There you can define specific targets for both targets.

<distributionManagement>
  <repository>
    <id>releases</id>
    <name>releases</name>
    <url>http://somerepo:8081/nexus/content/repositories/releases/</url>
  </repository>
  <snapshotRepository>
    <id>snapshots</id>
    <name>snapshots</name>
    <url>http://somerepo:8081/nexus/content/repositories/snapshots/</url>
  </snapshotRepository>
</distributionManagement>

这篇关于使用 maven 3.0.5 发布快照到 nexus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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