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:<
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'
}
the dependency configuration of compile is deprecated in gradle 4.x. You need to replace that with default. So the above code-snippet becomes:
dependencies {
implementation 'com.google.inject:guice:4.0-beta5'
}
task copyDependencies(type: Copy) {
from configurations.default
into 'dependencies'
}
This is the equivalent Kotlin DSL version (added the buildDir prefix to make it copy the dependencies in the build folder):
task("copyDependencies", Copy::class) {
from(configurations.default).into("$buildDir/dependencies")
}
Here's another way to include dependencies. This could also be war instead of jar for web archives.
dependencies {
implementation 'my.group1:my-module1:0.0.1'
implementation 'my.group2:my-module2:0.0.1'
}
jar {
from {
configurations.compileClasspath.filter { it.exists() }.collect { it.isDirectory() ? it : zipTree(it) }
}
}