如何在不编写任何pom.xml的情况下从Maven Central下载jar [英] How to download jars from Maven Central without writing any pom.xml

查看:144
本文介绍了如何在不编写任何pom.xml的情况下从Maven Central下载jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要类似以下的内容.

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,无需开发自己的工具,请使用mvndependency:get.这是对这个问题的正确答案.

No need to setup a POM, no need to develop your own tool, use mvn dependency:get. That's the right answer to this question.

这篇关于如何在不编写任何pom.xml的情况下从Maven Central下载jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆