I have a non-standard project layout.
How can I use Gradle to just download a bunch of JAR dependencies into a lib
directory, under the same directory where build.gradle
is? For now, I don't need it to do anything else.
Here is what I have so far:
apply plugin: "java"
repositories {
mavenCentral()
}
buildDir = "."
libsDirName = "lib"
dependencies {
runtime group: "...", name: "...", version: "..."
}
If I run gradle build
, it builds an empty JAR file in the lib
directory, instead of downloading my dependencies there.
Switching "lib" with "." in the properties does not work either.
The Gradle dependency cache consists of two storage types located under GRADLE_USER_HOME/caches : A file-based store of downloaded artifacts, including binaries like jars as well as raw downloaded meta-data like POM files and Ivy files.
The result JAR will be created in build/libs/ directory by default.
Gradle will look for a dependency in each repository in the order they are specified, stopping at the first repository that contains the requested module. To find out more about defining repositories, have a look at Declaring Repositories.
Something like the following should work:
apply plugin: 'base'
repositories {
mavenCentral()
}
configurations {
toCopy
}
dependencies {
toCopy 'com.google.guava:guava:18.0'
toCopy 'com.fasterxml.jackson.core:jackson-databind:2.4.3'
}
task download(type: Copy) {
from configurations.toCopy
into 'lib'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With