如何获得IntelliJ来解析自定义源集的Gradle依赖关系? [英] How do I get IntelliJ to resolve Gradle dependencies for custom source sets?
问题描述
当IntelliJ打开一个 build.gradle
文件时,它将生成一个IntelliJ项目,解决Gradle依赖项并添加到项目范围中。这对于编译源代码集和测试源代码集非常适用,但是我无法将其用于自定义源代码集。
When IntelliJ opens a build.gradle
file it will generate an IntelliJ project with the Gradle dependencies resolved and added to the project scope. This works great for the "compile" source set and the "test" source set, however I can not get this to work for custom source sets.
我想让IntelliJ解决我的 componentTest
源集的依赖关系。
I want to have IntelliJ resolve the dependencies for my componentTest
source set. How do I tell IntelliJ to resolve these dependencies and add them to scope?
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 b
Details: 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
This is described in Gradle user guide - http://www.gradle.org/docs/current/userguide/idea_plugin.html and http://www.gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html
您需要添加如下内容:
You will need to add something like:
idea {
module {
scopes.TEST.plus += [ configurations.componentTestCompile ]
}
}
添加到您的 build.gradle
文件中。
这篇关于如何获得IntelliJ来解析自定义源集的Gradle依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!