Configuring per-module JetGradle output directory


I work in an organization of mostly Eclipse users, on a project built with Gradle. The application I work on consists of many (well over a hundred) small plugins each of which is built as a sub-project of one root project in Gradle. Previously when I tried to import this project with JetGradle, the number of modules was too many for it to handle, so up until now I've been generating Eclipse project files (as my Eclipse-using compatriots do) and using the Eclipse integration to import those. As of upgrading to IDEA 13, it looks like the improvements to JetGradle are sufficient to allow me to import my project, which is very exciting. The main advantage it would afford me is auto-importing new sub-projects upon refresh. This is actually a very big improvement, since switching branches on this project often comes with some additional plugins, which up until now has required me to re-generate project files, which can be quite slow.

There's now just one obstacle to me using JetGradle on this project, and it has to do with the output directories. Our application is run by a plugin manager, and this plugin manager looks in very specific directories for the build output of each plugin. In particular, for each plugin it looks in $plugin_dir$/ecbuild (default Eclipse output path) and $plugin_dir$/build/main/classes (default Gradle output path). Unfortunately it looks like by default, JetGradle configures all modules to inherit their build output directory from the root project. I'm trying to find a way to configure each module to have its own build output relative to that module's directory, but I haven't had any luck. I tried setting the project output directory using the $MODULE_DIR$ macro which seems to work in some places, but not here. I could write a script that rewrites the IDEA configuration files for each module, but that would defeat the purpose of switching to JetGradle for me (the ease of switching between branches with different sets of modules). Is there some other way I can configure each module in my project to have a build path relative to the module's directory ($MODULE_DIR$/ecbuild would be the easiest).


Comment actions Permalink

Hi, Dylan

You can configure this in your build.gradle script or in gradle init script:

allprojects{   apply plugin: 'idea'   idea {     module {       inheritOutputDirs = false       outputDir = file('build/classes/main')       testOutputDir = file('build/classes/test')     }   } }

Comment actions Permalink

Excellent, that did it! For some reason I thought the Gradle IDEA plugin was only for generating IDEA project files, I didn't realize JetGradle would pick up on those settings. Thanks so much!


Please sign in to leave a comment.