为什么"依赖"命令返回一些" FAILED"只有一个依赖项的空项目的结果,JUnit?

时间:2017-10-13 07:25:28

标签: gradle

我有build.gradle这样:

apply plugin: 'java'

dependencies{
   compile 'junit:junit:4.12'
}

当我运行gradle dependencies时,我得到:

------------------------------------------------------------
Root project
------------------------------------------------------------

apiElements - API elements for main. (n)
No dependencies

archives - Configuration for archive artifacts.
No dependencies

compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
\--- junit:junit:4.12 FAILED

compileClasspath - Compile classpath for source set 'main'.
\--- junit:junit:4.12 FAILED

compileOnly - Compile only dependencies for source set 'main'.
No dependencies

default - Configuration for default artifacts.
\--- junit:junit:4.12 FAILED

implementation - Implementation only dependencies for source set 'main'. (n)
No dependencies

runtime - Runtime dependencies for source set 'main' (deprecated, use 'runtimeOnly ' instead).
\--- junit:junit:4.12 FAILED

runtimeClasspath - Runtime classpath of source set 'main'.
\--- junit:junit:4.12 FAILED

runtimeElements - Elements of runtime for main. (n)
No dependencies

runtimeOnly - Runtime only dependencies for source set 'main'. (n)
No dependencies

testCompile - Dependencies for source set 'test' (deprecated, use 'testImplementation ' instead).
\--- junit:junit:4.12 FAILED

testCompileClasspath - Compile classpath for source set 'test'.
\--- junit:junit:4.12 FAILED

testCompileOnly - Compile only dependencies for source set 'test'.
No dependencies

testImplementation - Implementation only dependencies for source set 'test'. (n)
No dependencies

testRuntime - Runtime dependencies for source set 'test' (deprecated, use 'testRuntimeOnly ' instead).
\--- junit:junit:4.12 FAILED

testRuntimeClasspath - Runtime classpath of source set 'test'.
\--- junit:junit:4.12 FAILED

testRuntimeOnly - Runtime only dependencies for source set 'test'. (n)
No dependencies

为什么存在 FAILED 依赖关系? 什么已弃用,使用'实施'相反是什么意思?

我也用过:

testImplementation 'junit:junit:4.12'

但同样的命令仍会返回 FAILED 部分:testCompileClasspathtestRuntimeClasspath

为什么会这样?

1 个答案:

答案 0 :(得分:1)

如果您尚未定义repositories块,则gradle将打印依赖项并将其标记为FAILED,因为它尚未正确解析(没有定义依赖项所在的位置)已经取得了。)

compile vs implementation看看here