【问题标题】:Maven dependency:copy artifact with base versionMaven 依赖:使用基本版本复制工件
【发布时间】:2017-05-04 14:57:22
【问题描述】:

我正在尝试使用 maven 通过命令行下载一些工件。我只知道工件的基本版本,但它们在 nexus 存储库中有一个单独的时间戳。

例如:

工件com.mycompany.subject:any-artifact:3.0.0-SNAPSHOT:war:plugins 在nexus 存储库中具有以下坐标com.mycompany.subject:any-artifact:3.0.0-20161212.140040-1:war:plugins

我想像这样下载工件:

 mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:copy -Dartifact=com.mycompany.subject:any-artifact:3.0.0-SNAPSHOT:war:plugins -DoutputDirectory=./my-tmp 

我在文档中找到了-Dmdep.useBaseVersion 选项,但这只会将下载的工件与基本版本一起保存。

编辑:

问题是,我只知道工件的基本版本,例如3.0.0-SNAPSHOT,当我尝试像上面那样从 nexus 下载它时,它失败了,因为 nexus 中的版本带有时间戳。

maven-metadata.xml:

<metadata>
  <groupId>com.mycompany.subject</groupId>
  <artifactId>any-artifact</artifactId>
  <versioning>
    <versions>
        <version>3.0.0-SNAPSHOT</version>
    </versions>
    <lastUpdated>20161214160043</lastUpdated>
  </versioning>
</metadata>

错误堆栈跟踪:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.319 s
[INFO] Finished at: 2016-12-19T15:04:06+01:00
[INFO] Final Memory: 16M/298M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.10:copy (default-cli) on project standalone-pom: Unable to find artifact. Could not find artifact com.mycompany.subject:any-artifact:3.0.0-SNAPSHOT in <remote-repository-id> (https://<nexus-repo-url>/nexus/repository/<specified-repository>)
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId ...
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId ...
[ERROR]
[ERROR]
[ERROR] com.mycompany.subject:any-artifact:3.0.0-SNAPSHOT
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] remote-repository-id (https://<nexus-repo-url>/nexus/repository/<specified-repository>),
[ERROR] -> [Help 1]

【问题讨论】:

  • 目前有什么问题?你在寻找什么结果?
  • 请查看我的编辑。我想下载带有基本版本的工件,尽管该版本在存储库中有一个时间戳。
  • 这应该不会造成问题。工件管理员应该了解3.0.0-SNAPSHOT 并下载最新的时间戳快照。您的 Nexus 中可能存在错误配置。检查http://yourNexusUrl/com/mycompany/subject/any-artifact 中的文件maven-metadata.xml。它看起来像什么?
  • @Tunaki 看问题,我上传了 maven-metadata.xml
  • 是的,所以使用3.0.0-SNAPSHOT 应该没有任何问题。使用时出现什么错误信息?

标签: maven maven-dependency-plugin maven-metadata


【解决方案1】:

问题是项目在存储库中没有 pom.xml,因此 maven 可能需要带有时间戳等的确切版本号。

现在,我使用 -DgeneratePom=true 选项部署工件,并且我可以仅使用基本版本号从存储库下载最新的工件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-18
    • 1970-01-01
    • 2020-07-26
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-30
    相关资源
    最近更新 更多