2012-02-23 189 views
3

我使用命令行中的maven-dependency-plugin来下载单个文件,但它总是在我的本地存储库中,对于我的特殊用例,我希望它是下载到当前目录。Maven依赖项插件忽略目标

我使用插件的版本2.4,它应该支持-Ddestination作为备用下载站点;然而,我无法让它工作。运行Maven的调试模式似乎表明,目标参数被忽略......

我运行了以下内容:

M:\>mvn -e -X org.apache.maven.plugins:maven-dependency-plugin:2.4:get \ 
-Ddestination=M:\test \ 
-DremoteRepositories=http://nexus-repo:8080/nexus/content/repositories/snapshots \ 
-Dartifact=com.company.Common:CommonLibs:1.12.0-SNAPSHOT:tar \ 
-Dtransitive=false 

...但得到这个...

[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-dependency-plugin:2.4:get' --> 
[DEBUG] (f) artifact = com.company.Common:CommonLibs:1.12.0-SNAPSHOT:tar 
[DEBUG] (f) localRepository = Repository[local|file://C:\Subversion\LocalMavenRepo] 
[DEBUG] (f) packaging = jar 
[DEBUG] (f) pomRemoteRepositories = [Repository[central|http://repo1.maven.org/maven2]] 
[DEBUG] (f) remoteRepositories = http://nexus-repo:8080/nexus/content/repositories/snapshots 
[DEBUG] (f) repositoryId = temp 
[DEBUG] (f) transitive = false 
[DEBUG] -- end configuration -- 
[INFO] [dependency:get {execution: default-cli}] 
[DEBUG] Skipping disabled repository central 
[INFO] snapshot com.company.Common:CommonLibs:1.12.0-SNAPSHOT: checking for updates from temp 
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http 

我做错了什么?

回答

8

请查阅文档here。它说:

表达式:$ {目的地}

这意味着你必须提供一个名为dest参数。尝试使用-Ddest=M:\test.tar。此外,它应该是下载的制品的文件名称,而不是目录。

+0

+1。这样可行。 – Yanflea 2012-02-23 14:59:33

+1

啊,谢谢你指出。我以前的工作是假设预期的表达式始终与参数名称相同。 :-) – RCross 2012-02-23 15:23:45