Suggested way to do live reload in Java Gradle project, after 2017.3
Hi. After the change in 2017.2 (described in IDEA-175337) Idea has separate output classes dir, not the one of Gradle. I have problems in efficient use of Idea. Neither way works efficiently. I would thought that having the same output directory would be best for me, but this is discouraged (IDEA-175172, search for "incremental").
I attach a project self-contained in a single gradle.build file. It generates a lot of source files, to make it easy to see the issue. Not really know how to attach, so see it on github. You may simply "gradle generSrc runApp". It is configured for 2000 source files, change it if you want to do it fast.
The goal is to have the following:
1. live reload works
2. classes files are built only once (not separately by gradle and idea)
3. during life reload only changed files are recompiled
In a big project all these things are a must. At work, where we have professional Intellij licence, a full build takes 40 minutes on modern workstations.
The first thing I tried was turning on "Delegate IDE build/run actions to gradle". But then points 1 and 3 fail and live reload does not work at all. I didn't try to ditch gradle plugin and use "gradle idea". The default settings with gradle plugin makes point 2 problematic (class files built twice).
Now just wondering about copying files between the 2 output directories, manually or with a task. Maybe this workaround would do the trick. We have 20 subprojects but this seems to be doable in gradle.
Please give a general advice. Thank you!
Please sign in to leave a comment.
Forgot to add, that we have already a similar article (Debugging and reloading of compiled classes in a gradle backed project), but it was written before the 2017.2/3 change.
I found one related issue on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-178036