【问题标题】:Deploy SNAPSHOT artifact and sources to Nexus from Maven command line从 Maven 命令行将 SNAPSHOT 工件和源部署到 Nexus
【发布时间】:2012-02-04 04:52:57
【问题描述】:

我正在尝试使用 maven 命令行部署一个 EXE 文件并将其压缩的源文件到 Sonatype Nexus。文件必须部署为 SNAPSHOT。

所以,我有 2 个文件:

-testXYZ.exe and source file
-testXYZ.zip

使用 maven 2.2.1 和此处描述的命令:

mvn deploy:deploy-file -Durl=file:///home/me/m2-repo \
                       -DrepositoryId=some.repo.id \
                       -Dfile=./path/to/artifact-name-1.0.jar \
                       -DpomFile=./path/to/pom.xml \
                       -Dsources=./path/to/artifact-name-1.0-sources.jar \
                       -Djavadoc=./path/to/artifact-name-1.0-javadoc.jar

我可以部署 EXE,但不能部署源代码,因为 maven 2.2.1 正在使用 deploy-plugin v2.5,并且直到 v2.7 才支持此命令。 我不允许使用更新版本的 maven,所以我尝试了不同的方法。

使用这两个后续命令,我可以部署这两个工件,但是,无法从 nexus 下载源代码。

call mvn deploy:deploy-file -DgroupId=com.xyz -DartifactId=testXYZ -Dversion=1.1.116-SNAPSHOT -Dpackaging=zip -Dfile=testXYZ.zip -Dclassifier=sources -Durl=http://build:8081/nexus/content/repositories/snapshots -DrepositoryId=nexus
call mvn deploy:deploy-file -DgroupId=com.xyz -DartifactId=testXYZ -Dversion=1.1.116-SNAPSHOT -Dpackaging=exe -Dfile=testXYZ.exe -Durl=http://build:8081/nexus/content/repositories/snapshots -DrepositoryId=nexus

部署后,我搜索 testXYZ 并单击工件源下载链接。 Nexus 说:

"路径上找不到项目 "com.xyz:testXYZ:1.1.116-SNAPSHOT:c=sources:e=jar"!"

问题是 maven 上传这些工件的方式:

Line form log file while source is uploading:
Uploaded: http://build:8081/nexus/content/repositories/snapshots/com/xyz/testXYZ/1.1.116-SNAPSHOT/testXYZ-1.1.116-20120106.111705-1-sources.zip
Line form log file while Main artifact is uploading:
Uploaded: http://build:8081/nexus/content/repositories/snapshots/com/xyz/testXYZ/1.1.116-SNAPSHOT/testXYZ-1.1.116-20120106.111709-2.exe

通知 111705-1 和 111705-2。如果我们希望 Nexus 能够生成正确的链接,最后一个数字必须相同。

这里描述了这种方法:

Deploying an artifact, its sources and javadoc using maven's deploy:deploy-file plugin

这里:

http://maven.apache.org/plugins/maven-install-plugin/examples/installing-secondary-artifacts.html

它适用于固定版本(例如 1.1.116),但不适用于 SNAPSHOT。

如果使用固定版本,则可以将 Exe 和 Zip 文件部署到 Nexus(如 jar 文件)。

所以,问题是: 有没有办法从命令行将工件和源 SNAPSHOT 部署到 Sonatype Nexus,并确保可以通过单击源和工件链接下载这些文件?

注意: 如果我禁用时间戳后缀,这可以工作,但我不想这样做。

-DuniqueVersion=false

谢谢,

马里安

【问题讨论】:

标签: nexus maven-deploy-plugin


【解决方案1】:

我找到了这个问题的部分解决方案。我可以像这样调用特定版本的 maven-deploy-plugin:

mvn org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file...

这样,工件和源快照可以部署到 Nexus,避免任何下载问题,但它的行为类似于

-DuniqueVersion=false

还在。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-19
    • 1970-01-01
    • 2014-11-02
    • 2018-04-07
    • 2013-03-06
    • 2017-09-18
    • 2016-10-19
    • 2019-05-11
    相关资源
    最近更新 更多