Adding module descriptors to existing JAR files
Gunnar Morling edited this page Oct 31, 2017
·
1 revision
To add a module descriptor for a given dependency, 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>generate-resources</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/modules</outputDirectory>
<modules>
<module>
<artifact>
<groupId>com.example</groupId>
<artifactId>example-core</artifactId>
<version>1.0.0.Final</version>
</artifact>
<moduleInfoSource>
module com.example.core {
requires java.logging;
exports com.example.api;
provides com.example.api.SomeService
with com.example.internal.SomeServiceImpl;
}
</moduleInfoSource>
</module>
<module>
...
</module>
</modules>
</configuration>
</execution>
</executions>
</plugin>
...
For each module to be processed, the following configuration options exist:
-
artifact
: The GAV coordinates of the artifact for which a descriptor should be generated (either this orfile
must be given) -
file
: Path to the file for which a descriptor should be generated (either this orartifact
must be given) -
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) -
version
: The version to be added to the module descriptor; if not given andartifact
is given, the artifact's version will be used; otherwise no version will be added (optional)
The modularized JARs can be found in the folder given via outputDirectory
.