R...
R...

Reputation: 2620

JPMS; trying to use a class from a dependecy module as mainClass fails in maven build

I have a Java maven project that has dependencies to other libraries. One of these dependecies has a Main class that can be used as < mainClass > in my maven-jar-plugin so I don't have have to create a Main class for my jar. Everything worked fine until I decided to move them to JPMS (Java Platform Module System)

I turned both my project (client module) and that dependency into java module and made sure all "exports" and "requires" are correct in module-info.java files.

but when I try to do mvn clean install I get the error during JAR creation and using -X I see this error that

Caused by: org.codehaus.plexus.archiver.ArchiverException: Could not create modular JAR file. The JDK jar tool exited with 1

looking at the log the only culprit I can see is this message about the package that contains the Main class :

Package a.b.c.d missing from ModulePackages class file attribute

Now if I create a Main class in my client module and use it as < mainClass > for maven-jar-plugin configuration, everything works.

I would like to know if this a limitation enforced by JPMS or something is missing in my module-info.javs files Also I didn't fully understoo the notion of "ModulePackages class file attribute". Where this attribute should be defined?


Another point that might shed more light is that, in the Main class that I created in my client module I can call the Main class of the other module without any problem. So the only problem is that I can not use that other Main class as the < mainClass > of my maven-jar-plugin config. could this be a limitation that the Main class of a module jar must be one of its own classes ? or this is a limitation maven jar plugin?

Upvotes: 0

Views: 40

Answers (0)

Related Questions