Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get IntelliJ to resolve Gradle dependencies for custom source sets?

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

like image 311
Mike Rylander Avatar asked Jul 02 '14 18:07

Mike Rylander


1 Answers

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.

like image 85
Radim Avatar answered Sep 18 '22 20:09

Radim