Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Java 9 modules from a single Maven module?

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?

like image 692
Alex Bondar Avatar asked Dec 18 '17 19:12

Alex Bondar


People also ask

What is multi module project in Maven?

A multi-module project is built from an aggregator POM that manages a group of submodules. In most cases, the aggregator is located in the project's root directory and must have packaging of type pom. The submodules are regular Maven projects, and they can be built separately or through the aggregator POM.

Does Maven support Java modules?

Actually, we can! In this tutorial, we'll learn how to create a multi-module Maven application using Java modules.

Can a Maven project have multiple pom files?

Yes you can use Maven Profiles to manage this. Obviously you can tweak this approach to suit your needs however works best.


1 Answers

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

like image 87
Nicolai Parlog Avatar answered Sep 23 '22 17:09

Nicolai Parlog