Adding Gradle depdencies to IntelliJ compiler classpath
gradle, intellij-idea, java
Solution
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.
Problem
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.