jwenjian/ghiblog

Maven: maven-dependency-plugin:get 通过命令行下载jar包到本地仓库 无需pom文件

jwenjian opened this issue · 0 comments

Apache Maven Dependency Plugin

dependency:get resolves a single artifact, eventually transitively, from a specified remote repository.

根据上述文档, 我们可以用下面的命令来实现在命令行中下载指定的依赖包到本地仓库, 无需pom文件.

mvn -DgroupId=commons-io -DartifactId=commons-io -Dversion=1.4 dependency:get

如果执行成功, 命令行会输出如下信息:

[INFO] Resolving commons-io:commons-io:jar:1.4 with transitive dependencies
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:09 min
[INFO] Finished at: 2019-06-24T13:44:49+08:00
[INFO] ------------------------------------------------------------------------

参数:

  • artifact

按固定格式groupId:artifactId:version[:packaging[:classifier]]组成的依赖信息
所以上述示例也可以写成: mvn -Dartifact=commons-io:commons-io:1.4 dependency:get

  • artifactId
  • classifier
  • groupId
  • packaging
  • remoteRepositories

逗号分隔的远程仓库地址, 可选, 如果不填会用settings.xml中配置的信息

  • transitive

是否同时依赖包的所有依赖, 默认为是

  • version