【问题标题】:Adding Gradle depdencies to IntelliJ compiler classpath将 Gradle 依赖项添加到 IntelliJ 编译器类路径
【发布时间】:2013-11-20 05:12:13
【问题描述】:

给定一个 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"
}

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

我们也非常感谢能够在 Eclipse 中进行微小更改的灵活解决方案。

【问题讨论】:

    标签: java intellij-idea gradle


    【解决方案1】:

    假设您已经安装了 Gradle 插件(Preferences>Plugins>Install JetBrains plugin>Gradle),使用 IntelliJ 12,只需单击 Refresh Gradle Project 即可将所有依赖项放在您的类路径中。

    【讨论】:

    • “首选项”在哪里?
    • 它在文件 -> 设置中。或者按 ctrl + alt + s
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 2015-08-12
      • 2017-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-28
      • 2014-09-18
      • 2014-11-18
      相关资源
      最近更新 更多