12

I have an interesting concern. I am used to multi-module Maven projects. Now I am investigating how to do the same but also using Jigsaw. Am right that every single Maven Module can have only one Jigsaw module? In IDE I can't create the second one inside the same Maven module.

So, is there any convention or workaround so far how to combine both sides of modules?

Nicolai Parlog
  • 47,972
  • 24
  • 125
  • 255
Alex Bondar
  • 1,167
  • 4
  • 18
  • 35
  • 4
    Simple answer to this is: Yes a single modules can have only a single module-info.java file which in consequence means having a single Jigsaw module. What do you mean by `convention or workaround so far how to combine both sides of modules?` – khmarbaise Dec 18 '17 at 19:58
  • I mean how it should be – Alex Bondar Dec 18 '17 at 20:16
  • It should be as you already described it. A single Jigsaw module into a single Maven module...or vs. single Maven module results into a single Jigsaw module (having only a single module-info.java file)... – khmarbaise Dec 18 '17 at 22:04
  • Voting to close this as off-topic. Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. Would have been good to see what you'd tried as well. – Naman Dec 19 '17 at 00:50

1 Answers1

27

When Project Jigsaw developed the Java Platform Module System it decided that a modular JAR is a regular JAR with a module descriptor, a module-info.class, in its root folder. That means a JAR can only define a single module. There have been request for multi-module JARs, but the feature was deferred to a future release.

That one-to-one relationship between JPMS modules and JARs taken together with Maven's one-to-one relationship between Maven modules and JARs leads to the fact that a Maven module can only contain a single JPMS module.

(I created a module system tutorial and a corresponding demo project that uses a multi-module Maven build to create modules - maybe they're helpful to you.)

Nicolai Parlog
  • 47,972
  • 24
  • 125
  • 255
  • 3
    This also leads to the fact that you have to manage your project module dependencies twice. Once in the module-infos and again in your poms, or am I missing something? – mipa Dec 21 '17 at 13:06
  • In principal yes, but IDEs should help. [Background](https://stackoverflow.com/q/43201997/2525313). – Nicolai Parlog Dec 21 '17 at 13:07
  • 1
    In principle IDEs should help but at the moment they just do the opposite. Eclipse is not even able to import a multi-module maven project correctly. All modules will end up on the class path instead of the module path. https://bugs.eclipse.org/bugs/show_bug.cgi?id=525251 – mipa Dec 21 '17 at 13:36
  • 4
    Give it time, the module system is a big change and not everything can work from day 1. – Nicolai Parlog Dec 21 '17 at 13:39