This pull request adds support for modular JAR files. Of course it was possible 
to create JAR files that contains `module-info.class` but the `jar` tools part 
of the JDK does more that that. It allows the module main class and version to 
be specified, adds the list of the packages included in the module and verifies 
that the module descriptor is correct.

This PR modifies the JAR plugin to use the new `ModularJarArchiver` so the 
above mentioned information can be added to the module descriptor as well to 
the validated.  `ModularJarArchiver` handles gracefully non-modular JAR 
archives so it is safe to be used for all JAR files without prior knowledge if 
the archive is going to contain `module-info.class` or not.

 `ModularJarArchiver` requires the JDK used to run Maven to be 9 or newer in 
order to modify the module descriptor as the current implementation 
(`JarToolModularJarArchiver`) uses the JDK `jar` tool and does not support tool 
chains. If the JDK used is 8 or older then `ModularJarArchiver` will gracefully 
fallback to treating the archive as regular JAR file and will just pack the 
module descriptor without modifying or validating it.

The current implementation does not allow the user to specify the module 
version, but that is not a problem as it is set by the compiler plugin. And if 
needed could easily be added later - `ModularJarArchiver` already support 
specifying the module version.


 - [x] I hereby declare this contribution to be licenced under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)


[ Full content available at: https://github.com/apache/maven-jar-plugin/pull/2 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to