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.
Assuming you've got Gradle plugin installed(Preferences>Plugins>Install JetBrains plugin>Gradle), using IntelliJ 12, just clicking on Refresh Gradle Project should put all dependencies in your classpath.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With