Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Java EE 7 Handbook: Gradle Multi-Modules Puzzle

DZone's Guide to

Java EE 7 Handbook: Gradle Multi-Modules Puzzle

· Java Zone
Free Resource

The single app analytics solutions to take your web and mobile apps to the next level.  Try today!  Brought to you in partnership with CA Technologies

Yesterday, I converted Gradle build code base for my upcoming Java EE 7 Developer Handbook book from individual 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 javaee7handbookfolder 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 eithergradle 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?

+PP+

CA App Experience Analytics, a whole new level of visibility. Learn more. Brought to you in partnership with CA Technologies.

Topics:

Published at DZone with permission of Peter Pilgrim, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}