Java 如何让IntelliJ解析自定义源集的渐变依赖关系?
当IntelliJ打开一个Java 如何让IntelliJ解析自定义源集的渐变依赖关系?,java,intellij-idea,gradle,dependency-management,Java,Intellij Idea,Gradle,Dependency Management,当IntelliJ打开一个build.gradle文件时,它将生成一个IntelliJ项目,其中gradle依赖项已解析并添加到项目范围中。这对于“编译”源代码集和“测试”源代码集非常有效,但是对于自定义源代码集,我无法实现这一点 我想让IntelliJ解析我的componentTest源代码集的依赖项。我如何告诉IntelliJ解决这些依赖关系并将它们添加到范围中 dependencies { // main source set, "compile" scope in Intelli
build.gradle
文件时,它将生成一个IntelliJ项目,其中gradle依赖项已解析并添加到项目范围中。这对于“编译”源代码集和“测试”源代码集非常有效,但是对于自定义源代码集,我无法实现这一点
我想让IntelliJ解析我的componentTest
源代码集的依赖项。我如何告诉IntelliJ解决这些依赖关系并将它们添加到范围中
dependencies {
// main source set, "compile" scope in IntelliJ
compile(group: 'com.google.guava', name: 'guava', version: '18.0')
// test source set, "test" scope in IntelliJ
testCompile(group: 'junit', name: 'junit', version: '4.11')
// my custom source set, not added to any scope in IntelliJ
componentTestCompile(group: 'org.springframework', name: 'spring', version: '3.0.7')
}
详细信息:IntelliJ 13.1.2,Gradle 1.11这在Gradle用户指南和 您需要添加以下内容:
idea {
module {
scopes.TEST.plus += [ configurations.componentTestCompile ]
}
}
转到您的
build.gradle
文件。感谢您添加文档链接!从gradle 3.1开始,我有[configurations.testCompile]。不过,谢谢你的回答!