How to set per-module compile output path for Reload Changed Classes?
I have a Gradle-based project with multiple modules. The compile output path for each module is set to (module name)/target/classes and this works fine most of the time: when I click the Run or Debug buttons, the compiled classes for the module I'm running and for the modules it depends on are put in the appropriate per-module target subdirectories. Unrelated modules aren't compiled.
But when I use Reload Changed Classes while debugging, the entire project, even modules that aren't dependencies of the running process, gets compiled from scratch and the output is written to a top-level "build" directory at the root of the project.
Is there a way to get Reload Changed Classes to use the same per-module output path configuration as Run / Debug?
Please sign in to leave a comment.
Looks like a bug, please report at https://youtrack.jetbrains.com/issues/IDEA with a sample to reproduce.
I dug into this a little more and I was somewhat wrong. It seems IntelliJ *is* obeying the output path settings for the Java classes, but it is creating the "build" directory to copy resources into. Our project has a lot of resources so the size of the directory was fooling me.
The underlying cause is that when you import a Gradle project, IntelliJ picks up the build directory setting from Gradle but only applies it to the xyz_main and xyz_test modules, not the top-level xyz module where the resources live. You can edit the output directories by hand in the IntelliJ UI, but of course your changes go away the next time IntelliJ resynchronizes with Gradle.
I don't know whether this is a Gradle IDEA plugin issue or an IntelliJ Gradle integration issue, but I'll file a report on it.