当 IntelliJ 打开一个 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 用户指南中有描述 - http://www.gradle.org/docs/current/userguide/idea_plugin.html和 http://www.gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html
您需要添加如下内容:
idea {
module {
scopes.TEST.plus += [ configurations.componentTestCompile ]
}
}
到你的 build.gradle
文件。
关于java - 如何让 IntelliJ 解决自定义源集的 Gradle 依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24538929/