Multiple Java 9 modules from a single Maven module?
Asked Answered
C

1

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?

Carthy answered 18/12, 2017 at 19:43 Comment(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?Initiatory
I mean how it should beCarthy
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)...Initiatory
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.Lycaon
D
28

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.)

Deluxe answered 19/12, 2017 at 8:20 Comment(4)
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?Sewn
In principal yes, but IDEs should help. Background.Deluxe
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. bugs.eclipse.org/bugs/show_bug.cgi?id=525251Sewn
Give it time, the module system is a big change and not everything can work from day 1.Deluxe

© 2022 - 2024 — McMap. All rights reserved.