【问题标题】:Adding a maven (distribution) repository on the command line在命令行上添加一个 maven (distribution) 存储库
【发布时间】:2012-09-15 07:00:50
【问题描述】:
我认为这应该是可能的,但我没有找到任何与之相关的内容,因为我发现的所有内容都与依赖存储库有关。
我想做的是定义 maven(例如部署或发布插件)推送工件的存储库。如何在命令行上定义它?我假设它是-Dsomething
更新:当我仔细阅读 jenkins 错误输出时,它提示使用:
-DaltDeploymentRepository=id::layout::url
使用它的格式是什么?什么是布局参数?
【问题讨论】:
标签:
maven
command-line
continuous-integration
repository
【解决方案1】:
最简单的方法是阅读描述格式的documentation about the maven-deploy-plugin:
mvn -DaltDeploymentRepository=repositoryId::default::http://WhatEverURL
在 distributionManagement 中,您通常会给出以下内容:
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>MyCo Internal Repository</name>
<url>Host to Company Repository</url>
</repository>
</distributionManagement>
如果您想在这种情况下使用不同的 URL,您需要提供:
mvn -DaltDeploymentRepository=internal.repo::default::http://WhatEverURL
本例中的 default 是 maven repository layout 的默认值。
【讨论】:
-
-
只是对命令行的更正。根据文档应该是这样的:“mvn -daltDeploymentRepository=internal.repo::default::WhatEverURL”
-
【解决方案2】:
在您的 pom.xml 中,您应该将 distributionManagement 配置添加到部署位置。
在以下示例中,我使用文件系统作为位置。
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
.........
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Internal repo</name>
<url>file:///home/thara/testesb/in</url>
</repository>
</distributionManagement>
............
</project>
同样的事情可以通过以下命令完成:
mvn deploy -DaltDeploymentRepository=internal.repo::default::file:///home/thara/testesb/in