Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

Gradle equivalent to Maven's "copy-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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

EDIT

From gradle 4+ it will be:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...