Gradle等同于Maven的“复制依赖”? [英] Gradle equivalent to Maven's "copy-dependencies"?

查看:132
本文介绍了Gradle等同于Maven的“复制依赖”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Maven-land中,只要简单地拉下特定POM文件的传递依赖关系,就打开一个shell,导航到POM所在的位置,然后运行:

  mvn依赖:copy-dependencies 

boom ,Maven会在当前目录内创建一个 target / 目录,并将所有可传递获取的JAR放置到该位置。



我现在正在尝试切换到Gradle,但Gradle似乎没有相同的功能。所以我问: Gradle是否等价于Maven的 copy-dependencies 如果是这样,有人可以提供一个例子吗?如果没有,其他开发人员是否认为这对Gradle社区是一个有价值的贡献?

没有相当于<$ c

  apply插件:$ c> copy-dependencies 在gradle中,但这是一个任务: 'java'
$ b $ repositories {
mavenCentral()
}

依赖项{
compile'c​​om.google.inject:guice:4.0 -beta5'
}

任务copyDependencies(类型:复制){
from configurations.compile
到'dependencies'
}

是否值得做贡献?你可以看到这很容易做到,所以我不这么认为。


In Maven-land, anytime I want to simply pull down the transitive dependencies for a particular POM file, I just open a shell, navigate to where the POM is located, and run:

mvn dependency:copy-dependencies

And boom, Maven creates a target/ directory inside the current one and places all the transitively-fetched JARs to that location.

I am now trying to make the switch over to Gradle, but Gradle doesn't seem to have the same feature. So I ask: Does Gradle have an equivalent to Maven's copy-dependencies? If so, can someone provide an example? If not, would other devs find this to be a worthwhile contribution to the Gradle community?

解决方案

There's no equivalent of copy-dependencies in gradle but here's a task that does it:

apply plugin: 'java'

repositories {
   mavenCentral()
}

dependencies {
   compile 'com.google.inject:guice:4.0-beta5'
}

task copyDependencies(type: Copy) {
   from configurations.compile
   into 'dependencies'
}

Is it worthwhile to do a contribution? AS You can see it's really easy to do, so I don't think so.

这篇关于Gradle等同于Maven的“复制依赖”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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