gradle - 如何在gradle中下载依赖项

标签 gradle

我有一个自定义编译任务。

task compileSpeedTest(type: JavaCompile) {
    classpath = files('build')
    source = fileTree('src/test/java/speed')
    destinationDir = file('bin')
}

Gradle 在执行之前不会尝试下载依赖项。
我在任何地方都找不到一个任务名称来将它添加到列表中。

最佳答案

如果您确实需要将它们下载到文件夹中,则可以下载 Java 依赖项。

例子:

apply plugin: 'java'

dependencies {
  runtime group: 'com.netflix.exhibitor', name: 'exhibitor-standalone', version: '1.5.2'
  runtime group: 'org.apache.zookeeper',  name: 'zookeeper', version: '3.4.6'
}

repositories { mavenCentral() }

task getDeps(type: Copy) {
  from sourceSets.main.runtimeClasspath
  into 'runtime/'
}

将依赖项(及其依赖项)下载到文件夹 runtime当你执行 gradle getDeps .

关于gradle - 如何在gradle中下载依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21814652/

相关文章:

git - 尝试运行gradle build时无法读取文件/usr/local/git/etc/gitconfig

android - 用于搜索要在 build.gradle 中使用的 android 库的网站

java - 使用 Gradle 版本 2.2.3 在 android studio 项目中无法识别方法 testCompile?

java - Gradle war 因编译任务失败

android - Volley 作为依赖

maven - 是否可以在类似于 Maven install :install-file? 的 gradle 中将文件安装到本地缓存

android构建错误错误:In <declare-styleable> FontFamilyFont,无法找到属性android:fontVariationSettings

android - 使用Android上的Google登录进行身份验证会构建它并出错

Android Studio Gradle 版本 5.1.1 问题

android - 为什么 Gradle 无法解析 Kotlin Gradle 插件