web-dev-qa-db-ja.com

IntelliJにカスタムソースセットのGradle依存関係を解決させるにはどうすればよいですか?

IntelliJがbuild.gradleファイルを開くと、Gradleの依存関係が解決され、プロジェクトスコープに追加されたIntelliJプロジェクトが生成されます。これは「コンパイル」ソースセットと「テスト」ソースセットには最適ですが、カスタムソースセットでは機能しません。

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

13
Mike Rylander

これについては、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ファイルに。

18
Radim