I'd like to download an artifact and its dependencies at the command line. I.e.
我想在命令行下载工件及其依赖项。即
mvn [some plugin]:[goal] -DartifactId=[artifactId] -DgroupId=[groupId] -Dversion=[version]
I've tried mvn dependency:get but this seems to require a list of remote repositories. I want mvn to use what's already specified in settings.xml
我尝试过mvn依赖:get但这似乎需要一个远程存储库列表。我希望mvn使用settings.xml中已经指定的内容
I've also tried the maven-download-plugin but this doesn't seem to work properly (it tried downloading xerces-impl as a transitive dependency of ant and failed to resolve it. Neither xerces-impl nor ant are dependencies of my artifact).
我也尝试了maven-download-plugin但这似乎没有正常工作(它尝试下载xerces-impl作为ant的传递依赖并且无法解决它.xerces-impl和ant都不是我的工件的依赖项)。
Your help would be appreciated.
非常感谢您的帮助。
4 个解决方案
#1
22
Try using the latest version of dependency:get, it works for me
尝试使用最新版本的依赖项:get,它适用于我
mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DartifactId=[artifactId] -DgroupId=[groupId] -Dversion=[version]
works for me
适合我
#2
28
The copy
goal is more appropriate here and it lets you specify an output directory as well (which is deprecated in the get
goal):
复制目标在这里更合适,它也允许您指定输出目录(在get目标中已弃用):
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:copy -Dartifact=groupId:artifactId:version[:packaging][:classifier] -DoutputDirectory=[target] -Dmdep.useBaseVersion=true
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.
mdep.useBaseVersion = true将从快照构建中删除时间戳。
#3
2
Example to download version 6.9.4 of TestNG to your local ~/.m2/repository (uses maven-dependency-plugin:get):
将TestNG版本6.9.4下载到本地〜/ .m2 / repository的示例(使用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):
将JUnit 4.11版下载到当前工作目录的示例(使用maven-dependency-plugin:copy):
mvn org.apache.maven.plugins:maven-dependency-plugin:RELEASE:copy \
-Dartifact=junit:junit:4.11:jar
#4
0
The simplest solution would be to create a simple pom with the appropriate dependencies and do mvn clean package on that mini project...
最简单的解决方案是创建一个具有适当依赖关系的简单pom,并在该迷你项目上执行mvn clean包...
#1
22
Try using the latest version of dependency:get, it works for me
尝试使用最新版本的依赖项:get,它适用于我
mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DartifactId=[artifactId] -DgroupId=[groupId] -Dversion=[version]
works for me
适合我
#2
28
The copy
goal is more appropriate here and it lets you specify an output directory as well (which is deprecated in the get
goal):
复制目标在这里更合适,它也允许您指定输出目录(在get目标中已弃用):
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:copy -Dartifact=groupId:artifactId:version[:packaging][:classifier] -DoutputDirectory=[target] -Dmdep.useBaseVersion=true
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.
mdep.useBaseVersion = true将从快照构建中删除时间戳。
#3
2
Example to download version 6.9.4 of TestNG to your local ~/.m2/repository (uses maven-dependency-plugin:get):
将TestNG版本6.9.4下载到本地〜/ .m2 / repository的示例(使用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):
将JUnit 4.11版下载到当前工作目录的示例(使用maven-dependency-plugin:copy):
mvn org.apache.maven.plugins:maven-dependency-plugin:RELEASE:copy \
-Dartifact=junit:junit:4.11:jar
#4
0
The simplest solution would be to create a simple pom with the appropriate dependencies and do mvn clean package on that mini project...
最简单的解决方案是创建一个具有适当依赖关系的简单pom,并在该迷你项目上执行mvn clean包...