Gradle不下载测试依赖项 [英] Gradle not downloading test dependencies

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

问题描述

我对Gradle很新,我想用Gradle下载我所有的测试依赖项。我使用 gradle init 来生成我的构建文件,并从我以前的脚本中复制了一些依赖关系。但是,在项目根目录下使用 gradle --refresh-dependencies 时,测试依赖关系仍然不能下载。



我试图寻找答案,为什么发生这种情况,但他们似乎并没有解决我的问题。我的构建文件有什么问题吗?



特别是,我在下载了mockito和hamcrest之后。



建立文件:
$ b $ pre $ apply plugin:'java'

repositories {
mavenCentral()
}

依赖关系{
编译'org.slf4j:slf4j-api:1.7.5'

testCompilejunit:junit:4.11
testCompileorg.mockito:mockito-core:1.9.5
testCompileorg.hamcrest:hamcrest-library:1.3
}

test {
testLogging {
events'started','passed'
}
}

任务包装器(类型:包装器){gradleVersion ='1.11'}

我也使用Eclipse,如果有帮助的话。



编辑:在我的项目中添加Gradle特性后,它似乎工作。任何人都可以解释为什么?

解决方案

现在,我在将Gradle自然添加到项目后,日食文件。

I am very new with Gradle and I would like to download all my test dependencies using Gradle. I used gradle init to generate my build file, and copied some dependencis from my previous scripts. However upon using gradle --refresh-dependencies in the project root, the test dependencies still do not download.

I tried searching for answers as to why this happens, but they don't seem to fix my issue. Is there something wrong with my build file?

Particularly, I am after downloading mockito and hamcrest below.

build file:

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.5'

    testCompile "junit:junit:4.11"
    testCompile "org.mockito:mockito-core:1.9.5"
    testCompile "org.hamcrest:hamcrest-library:1.3"
}

test {
  testLogging {
    events 'started', 'passed'
  }
}

task wrapper(type: Wrapper) { gradleVersion = '1.11' }

I am also using Eclipse if that helps.

EDIT: After adding the Gradle nature to my project, it seemed to work. Can anyone explain why?

解决方案

It seemed to work now, after I added the Gradle nature to my project, then cleaning and regenerating eclipse files.

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

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