我想使用maven2命令行界面下载json-simple
库的源代码。因此,我将此 .pom 文件下载到 ~/project/pom.xml
http://json-simple.googlecode.com/svn/trunk/pom.xml
然后,使用相关SO问题的答案:How to install Maven artifact with sources from command line? ,我尝试使用以下命令下载源代码,
$ cd ~/project
$ mvn eclipse:eclipse -DdownloadSources=true
$ ls
输出仅为pom.xml
。怎么了?
$ mvn --version
Apache Maven 2.2.1 (rdebian-8)
最佳答案
使用get dependency的目标插件
完整命令行(在某个地方执行 - 你不需要 pom)
mvn -DgroupId=com.googlecode.json-simple
-DartifactId=json-simple
-Dversion=1.1.1
-Dclassifier=sources
-DremoteRepositories=http://nexus.dmz1.heuboe.hbintern:8080/nexus/content/repositories/central/
org.apache.maven.plugins:maven-dependency-plugin:2.8:get
或者作为单行
mvn -DgroupId=com.googlecode.json-simple -DartifactId=json-simple -Dversion=1.1.1 -Dclassifier=sources -DremoteRepositories=http://nexus.dmz1.heuboe.hbintern:8080/nexus/content/repositories/central/ org.apache.maven.plugins:maven-dependency-plugin:2.8:get
通常我使用 Maven 3,但我也在 Windows 上使用 Maven 2.2.1 进行了测试,它可以工作。
您还可以考虑使用 m2e eclipse 中的 Maven 集成(如果尚未安装,请检查 eclipse Marketplace 进行安装)而不是 maven-eclipse-plugin (eclipse:eclipse)。您可以使用 Eclipse 首选项来下载源代码。
关于maven-2 - Maven使用POM.xml命令行下载源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17799713/