问题
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.
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')
}
Details: IntelliJ 13.1.2, Gradle 1.11
回答1:
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 ]
}
}
to your build.gradle
file.
来源:https://stackoverflow.com/questions/24538929/how-do-i-get-intellij-to-resolve-gradle-dependencies-for-custom-source-sets