jar: Package a.b.c missing from ModulePackages class file attribute

211 Views Asked by At

I have two maven versions:

Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: /opt/netbeans-14/java/maven
Java version: 21.0.1, vendor: Oracle Corporation, runtime: /opt/jdk-21.0.1

and

Apache Maven 3.9.3 (21122926829f1ead511c958d89bd2f672198ae9f)
Maven home: /opt/netbeans-19/java/maven
Java version: 21.0.1, vendor: Oracle Corporation, runtime: /opt/jdk-21.0.1

When I compile my JPMS module with 3.8.5 (clean install) then it is build without any problems. When I compile the module with 3.9.3 (clean install) I get:

[INFO] --- jar:3.3.0:jar (default-jar) @ mymodule-impl ---
[INFO] Building jar: /home/pavel/mymodule-impl/target/mymodule-impl-1.0.0.jar
jar: Package a.b.c missing from ModulePackages class file attribute
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
Total time:  3.386 s
Finished at: 2023-11-03T20:34:05+02:00
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.3.0:jar (default-jar) on project mymodule-impl: Error assembling JAR: Could not create modular JAR file. The JDK jar tool exited with 1 -> [Help 1]

Could anyone say why it is not built in the second case? Is this a bug?

1

There are 1 best solutions below

0
On BEST ANSWER

I've found out what is the problem. If package a.b.c doesn't have classes inside then maven 3.8.5 compiles, but maven 3.9.3 gives Package a.b.c missing from ModulePackages class file attribute error. I had classes but all they were commented inside, so I couldn't see that the package is empty.