问题描述
我想要类似以下的内容.
I would like something like the following.
我只想要一个能够从Maven存储库下载jar及其依赖项的实用程序,而对我的项目的构建方式没有任何限制.
I want just an utility that is able to download jars and their dependencies from the Maven Repository without imposing no constraints on how my project should be built.
我想要这样的东西:
download-jar --dest=lib/ 'commons-io:commons-io:jar:1.4'
它应该也可以下载依赖项.
It should be able to download also the dependencies.
更新:
我不知道pom.xml应该是结构化的.
I wouldn't know about a pom.xml should be structured.
我唯一需要完成的任务是下载jar,我希望有一个可以完成此任务的工具,而不会让我烦恼过多的信息.
The only task I need to be accomplished is the download of the jars, I would like have a tool that could accomplish this task that doesn't bother me with superflous information.
有类似的东西吗?
推荐答案
如果要将maven依赖项下载到lib目录中,请使用具有copy-dependencies
函数的依赖项插件.
If you want to download maven dependencies into your lib directory use the dependency plugin with the copy-dependencies
function.
mvn -DoutputDirectory=./lib -DincludeArtifactIds=commons-logging,commons-io dependency:copy-dependencies
没有-DincludeArtifactIds
部分,您将下载每个依赖项.
Without the -DincludeArtifactIds
part you'll download every dependency.
如果您要下载没有特定项目的工件,请参见下文**:
If you want to download a an artifact without having a specific project *see below** :
mvn -DgroupId=commons-io -DartifactId=commons-io -Dversion=1.4 dependency:get
资源:
- maven.apache.org - dependency:copy-dependencies
- force Maven2 to copy dependencies into target/lib
- maven.apache.org - dependency:get *see below**
关于同一主题:
- Aggregate Dependencies in a Multi-Module Maven Project
- Set plugin's property on the command line in maven 2
- A simple command line to download a remote maven2 artifact to the local repository? *see below**
有趣的评论:
- * @ Pascal Thivent:
- *@Pascal Thivent :
这篇关于如何在不编写任何pom.xml的情况下从Maven Central下载jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!