将Gradle倾向添加到IntelliJ编译器类路径 [英] Adding Gradle depdencies to IntelliJ compiler classpath

查看:141
本文介绍了将Gradle倾向添加到IntelliJ编译器类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个 build.gradle ,它具有这样的依赖关系:

 依赖项{
编译fileTree(dir:'myLegacyLibsNotYetConverted / lib',包括:'* .jar')
编译fileTree(dir:'myOtherLegacyLibsNotYetConverted / lib',包括'* .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'
(...)

testCompilejunit:junit:4.11
testCompile fileTree(dir:legacyBuild / test-lib ,包括:* .jar)
(...)

providesCompilejavax.servlet:servlet-api:2.5
providesCompilejavax.servlet.jsp: jsp-api:2.2

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



一个灵活的解决方案,可以在Eclipse中进行小的修改,这也是非常值得赞赏的。

解决方案

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



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


Given a build.gradle that has dependencies like these:

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"
}

What is the easiest/recommended way to add them to the IntelliJ's IDE's classpath so that all my interactive compiler and tests have all the class dependencies they need? Is it possible to sync it every time it changes?

A flexible solution that could work in Eclipse with minor changes would be much appreciated too.

解决方案

The easiest solution is to use the IDE plugins. IntelliJ 13 (EAP) ships with great out-of-the-box support for Gradle. (I don't recommend to use the IntelliJ 12 JetGradle plugin as it's too limited.) For Eclipse there is the Eclipse Gradle Tooling. Both plugins will resync dependencies at the push of a button.

The other approach is to use the eclipse/idea Gradle plugins and (re)generate IDE project files whenever necessary. This approach is documented in the Gradle User Guide.

这篇关于将Gradle倾向添加到IntelliJ编译器类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆