Question

I'm trying to structure my application (built with Gradle and developed in IntelliJ, this seems pretty crucial here) in a modular way (using Guice for modules and DI). The thing is I would like modules to communicate only via interfaces, so ideally I'd like to achieve this kind of structure:

+-- project
   +-- module1
      +-- src
         +-- iface
         +-- impl
         +-- test
      +-- build.gradle
   ..
   +-- moduleX
      +-- src
         +-- iface
         +-- impl
         +-- test
      +-- build.gradle

And in build.gradle I'd like to just include project('moduleX', configuration : 'iface') or something similar.

In Gradle I can do it with sourceSets etc., that's all cool! But the problem is that IntelliJ doesn't recognize it since I do it in gradle scripts! For IntelliJ it's still just a single module.

This is pretty strange since even maven supported a similar project structure (if I remember correctly). Does this mean that there is some other way to achieve what I want? And that IntelliJ expects me to use that approach or does it just want me to separate iface and the rest as separate modules (a thing I want to avoid, I don't want too many modules in my projects since it slows down the dev environment)?

Was it helpful?

Solution

Rather than using source sets, you'd typically structure this as a multi-project build, which would be mapped to a multi-module project in IntelliJ, and a workspace with multiple projects in Eclipse. To learn more about multi-project builds, check out the corresponding chapter in the Gradle User Guide.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top