How do I download a Maven artifact at the command line without using dependency:get or maven-download-plugin?

元气小坏坏 提交于 2019-11-28 18:16:41

Try using the latest version of dependency:get, it works for me

mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DartifactId=[artifactId] -DgroupId=[groupId] -Dversion=[version]

works for me

The copy goal is more appropriate here and it lets you specify an output directory as well (which is deprecated in the get goal):

mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:copy -Dartifact=groupId:artifactId:version[:packaging][:classifier] -DoutputDirectory=[target] -Dmdep.useBaseVersion=true

mdep.useBaseVersion=true will remove timestamps from snapshot builds.

Example to download version 6.9.4 of TestNG to your local ~/.m2/repository (uses maven-dependency-plugin:get):

mvn org.apache.maven.plugins:maven-dependency-plugin:RELEASE:get \
-Dartifact=org.testng:testng:6.9.4:jar

Example to download version 4.11 of JUnit to your current working directory (uses maven-dependency-plugin:copy):

mvn org.apache.maven.plugins:maven-dependency-plugin:RELEASE:copy \
-Dartifact=junit:junit:4.11:jar

The simplest solution would be to create a simple pom with the appropriate dependencies and do mvn clean package on that mini project...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!