How can I use Gradle to just download JARs?

百般思念 提交于 2019-12-22 08:52:22

问题


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.


回答1:


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'
}


来源:https://stackoverflow.com/questions/32402541/how-can-i-use-gradle-to-just-download-jars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!