将第三方JAR部署到本地存储库

时间:2014-06-12 22:58:38

标签: java maven

我有一个jar,我想使用deploy:deploy-file部署到本地目录。我应该将什么用于所需的-DrepositoryId和-Durl选项?

我目前的尝试:

egeller$ mvn deploy:deploy-file -DgroupId=net.sample \
-DartifactId=sample-artifact -Dversion=4.5.1  -Dpackaging=jar \
-Dfile=sample-sdk.jar -DrepositoryId=local \
-Durl=file://Users/egeller/agent/deploy-agent/

导致以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: 
Failed to deploy artifacts: Could not transfer artifact net.sample:sample-artifact:jar:4.5.1 from/to local (file://Users/egeller/agent/deploy-agent/): 
Repository path /egeller/agent/deploy-agent/ does not exist, and cannot be created.

谢谢!

2 个答案:

答案 0 :(得分:1)

  

存储库路径/ egeller / agent / deploy-agent /不存在,无法创建。

表示您根据评论讨论提供了错误的路径

答案 1 :(得分:1)

问题是我应该将-Durl设置为相对于当前工作目录的目录,而不是绝对路径。在这种情况下,-DrepositoryId可以留空。

工作版:

egeller$ mvn deploy:deploy-file -DgroupId=net.sample \
-DartifactId=sample-artifact -Dversion=4.5.1  -Dpackaging=jar \
-Dfile=sample-sdk.jar \
-Durl=file://repo-name