我有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 部分:testCompileClasspath
和testRuntimeClasspath
。
为什么会这样?
答案 0 :(得分:1)
如果您尚未定义repositories
块,则gradle将打印依赖项并将其标记为FAILED
,因为它尚未正确解析(没有定义依赖项所在的位置)已经取得了。)
请compile
vs implementation
看看here。