2011-08-29 141 views
6

我正在使用Maven 3.我試圖將第三方工件部署到遠程存儲庫,但遇到了一個奇怪的錯誤。我使用部署的命令是Maven:無法將第三方JAR部署到遠程存儲庫

mvn deploy:deploy-file -DgroupId=com.myco.util.ant \ 
    -DartifactId=selenium-ant-task \ 
    -Dversion=1.4 \ 
    -Dpackaging=jar \ 
    -Dfile=/Users/davea/.m2/repository/com/myco/util/ant/selenium-ant-task/1.4/selenium-ant-task-1.4.jar \ 
    -DrepositoryId=sonatype-nexus \ 
    -Durl=http://sonatype.myco.com/nexus/content/repositories/releases 

而我得到的錯誤,當我運行此命令是

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy-file (default-cli) on project maven-selenium-plugin: The parameters 'url' for goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy-file are missing or invalid -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 

這是怎麼回事?我在我的〜/ .m2/settings.xml文件中定義了我的repositoryId,「ssonatype-nexus」,並驗證了這裏的憑據是正確的。

感謝您的任何幫助, - 戴夫

+1

'使用-X開關重新運行Maven以啓用完整的調試日誌記錄。'可以幫助您修復錯誤:) – Jacob

回答

1

似乎你的網址格式不正確。

嘗試:

-Durl =文件:// path_to_m2_repo

See here for more

編輯:請注意,在這種情況下,該URL用於本地回購。 Maven應該基於POM和-DrepositoryId部署到Nexus。

+0

URL格式設置無誤 - 儘管使用指南用作示例,您無需部署到文件位置(即使它位於文件系統上,它仍將被視爲遠程回購)。 –

+0

嗨,我不明白你的建議。我改變我的網址爲「-Durl = file:/// path/to/jar/I/want/to/deploy」,但我仍然遇到了錯誤。你能舉一個例子,使用我想要部署的文件的路徑和存儲庫ID嗎? – Dave

+0

從我從該文檔中瞭解到,Durl應該是本地存儲庫(或文件所在位置)的路徑,而不是您要部署的文件,這就是-Dfile的用途。 -DrepositoryID應與您在POM文件中的中指定的ID匹配。我假設這會將給定的Dfile推送到您的m2 repo(Durl)並將其部署到POM中定義的DrepositoryID,在這種情況下爲您的Nexus。如果這不起作用,我想看看你的POM中的屬性。 – Tony

3

deploy:deploy-file不打算在具有pom.xml文件的目錄中運行 - 您應該在其他位置運行它。如果您想要上傳一個特定的POM,請不要忘記-DpomFile參數,因爲默認值是生成一個基本參數。但是,我注意到你正在從本地存儲庫部署一個文件 - 如果這是由Maven構建的,那麼使用<distributionManagement>元素和deploy生命週期階段來完成部署工作當然更好。

相關問題