将Gradle depdencies添加到IntelliJ编译器类路径

Zer*_*ion 5 java intellij-idea gradle

给定一个build.gradle具有以下依赖关系:

dependencies {
    compile fileTree(dir: 'myLegacyLibsNotYetConverted/lib', include: '*.jar')
    compile fileTree(dir: 'myOtherLegacyLibsNotYetConverted/lib', include: '*.jar')
    compile 'org.springframework:spring-tx:3.1.2.RELEASE'
    compile 'org.springframework:spring-jms:3.1.2.RELEASE'
    compile 'org.springframework:spring-jdbc:3.1.2.RELEASE'
    (...)

    testCompile "junit:junit:4.11"
    testCompile fileTree(dir: "legacyBuild/test-lib", include: "*.jar")
    (...)

    providedCompile "javax.servlet:servlet-api:2.5"
    providedCompile "javax.servlet.jsp:jsp-api:2.2"
}
Run Code Online (Sandbox Code Playgroud)

将它们添加到IntelliJ的IDE类路径中的最简单/推荐的方法是什么,以便我的所有交互式编译器和测试都具有它们所需的所有类依赖项?是否可以在每次更改时同步它?

一个灵活的解决方案,可以在Eclipse中工作,只需稍作修改,也会非常感激.

edu*_*ohl 5

假设你已经安装了Gradle插件(首选项>插件>安装JetBrains插件> Gradle),使用IntelliJ 12,只需单击Refresh Gradle Project就可以将所有依赖项放在类路径中.


Pet*_*ser 2

最简单的解决方案是使用 IDE 插件。IntelliJ 13 (EAP) 为 Gradle 提供了强大的开箱即用支持。(我不建议使用 IntelliJ 12 JetGradle 插件,因为它的功能太有限。)对于 Eclipse,有Eclipse Gradle Tooling。只需按一下按钮,这两个插件就会重新同步依赖项。

另一种方法是使用eclipse/ ideaGradle 插件并在必要时(重新)生成 IDE 项目文件。这种方法记录在Gradle 用户指南中。