如何在gradle中下载依赖项 [英] How to download dependencies in gradle

查看:107
本文介绍了如何在gradle中下载依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a custom compile task.

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

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

Gradle doesn't try to download dependencies before its execution. I cannot find anywhere a task name which does it to add it on list dependsOn.

推荐答案

如果您确实需要将它们下载到文件夹中,则可以下载它们.

Downloading java dependencies is possible, if you actually really need to download them into a folder.

示例:

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

在执行 gradle getDeps 时,将依赖项(及其依赖项)下载到文件夹 runtime 中.

Download the dependencies (and their dependencies) into the folder runtime when you execute gradle getDeps.

这篇关于如何在gradle中下载依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆