Adding a module descriptor to the project JAR
Gunnar Morling edited this page Oct 31, 2017
·
1 revision
To add a module descriptor to the JAR produced by the current Maven project, configure the add-module-info goal as follows:
...
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0.Alpha2</version>
<executions>
<execution>
<id>add-module-infos</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<module>
<moduleInfo>
<name>com.example</name>
<exports>
!com.example.internal.*;
*;
</exports>
</moduleInfo>
</module>
</configuration>
</execution>
</executions>
</plugin>
...
The following configuration options exist for the <module>
configuration element:
-
moduleInfoSource
: Inline representation of a module-info.java descriptor (optional; either this ormoduleInfoFile
ormoduleInfo
must be given) -
moduleInfoFile
: Path to a module-info.java descriptor (optional; either this ormoduleInfoSource
ormoduleInfo
must be given) -
moduleInfo
: AmoduleInfo
configuration as used with thegenerate-module-info
goal (optional; either this ormoduleInfoSource
ormoduleInfoFile
must be given) -
mainClass
: The fully-qualified name of the main class to be added to the module descriptor (optional)
Note that moduleInfoSource
and moduleInfoFile
can be used on Java 8, allowing to add
a Java 9 module descriptor to your JAR also if you did not move to Java 9 for your own
build yet. moduleInfo
can only be used on Java 9 or later.