簡體   English   中英

Maven依賴項:復制帶有基本版本的工件

[英]Maven dependency:copy artifact with base version

我正在嘗試通過命令行使用Maven下載一些工件。 我只知道工件的基本版本,但是它們在nexus存儲庫中有單獨的時間戳。

例如:

工件com.mycompany.subject:any-artifact:3.0.0-SNAPSHOT:war:plugins具有以下坐標com.mycompany.subject:any-artifact:3.0.0-20161212.140040-1:war:plugins在nexus存儲庫中。

我想像這樣下載工件:

 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]

問題在於項目在存儲庫中沒有pom.xml,因此maven可能需要帶有時間戳等的確切版本號。

現在,我使用-DgeneratePom=true選項部署工件,並且只能使用基本版本號從存儲庫下載最新工件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM