Yesterday, I converted Gradle build code base for my upcoming Java EE 7 Developer Handbook book from invidual modules to multi-module. I thought I had this structure down, but I surprisingly I am stuck.
Here is my book’s code structure in folder hierarchy:
javaee7handbook javaee7handbook/build.gradle javaee7handbook/settings.gradle javaee7handbook/ch01 javaee7handbook/ch01/foo/build.gradle javaee7handbook/ch02 javaee7handbook/ch02/bar/build.gradle javaee7handbook/ch03 javaee7handbook/ch03/donkey/build.gradle javaee7handbook/ch04/jpa-simple javaee7handbook/ch04/jpa-simple/build.gradle
This structure runs for 14 chapters including appendices.
So I have master hierarchy defined in
settings.gradle and it looks like this:
include 'ch01/foo', 'ch02/bar', 'ch03/donkey', 'ch04/jpa-simple', ...
With Gradle multi-module build, readers can execute
gradle build from the root
javaee7handbook folder and everything will build and run to test to completely. This is great for readers of my book, they can get started very quickly and I am sure they love Gradle.
My problem is that want the novice users to go any sub folder / multi-module and execute either
gradle idea or
gradle eclipse and just see a single project view.
Whenever I open now a sub module say
javaee7handbook/ch04/jpa-simple/build.gradle I find that IntelliJ replicates the whole structure inside the sub module!!!
javaee7handbook/ch04/jpa-simple/ javaee7handbook/ch04/jpa-simple/ch01 javaee7handbook/ch04/jpa-simple/ch01/build.gradle javaee7handbook/ch04/jpa-simple/ch02 javaee7handbook/ch04/jpa-simple/ch02/build.gradle javaee7handbook/ch04/jpa-simple/ch03 javaee7handbook/ch04/jpa-simple/ch03/build.gradle javaee7handbook/ch04/jpa-simple/ch04 javaee7handbook/ch04/jpa-simple/ch04/build.gradle
The upper folders replicate into the sub module and IDEA gets totally confused. The JetGradle runs for a long time. This is not acceptable for people new to Java EE 7 and expect a seamless experience and yet Gradle is new way to build software. Android is already there and so is JavaFX 8. So what to do?
In fact, running
gradle idea generates a
javaee7handbook.iml and not the
jpa-simple.ipr that I expected file I saw when the Gradle project was not multimodule. I just my readers to see the project
jpa-simple and not bring in the rest of code related to other chapters. Can you help me figure out quickly how to solve this?