- Created by Robert Reiner, last modified on 14. Oct 2020
Describes the basic use cases with the plugin.
Basic Configuration
The basic usage of the plugin is this:
<plugin> <groupId>de.smartics.maven.plugin</groupId> <artifactId>smartics-jboss-modules-maven-plugin</artifactId> <version>2.1.5</version> <executions> <execution> <id>create-modules-archive</id> <goals> <goal>create-modules-archive</goal> </goals> <phase>package</phase> </execution> </executions> <configuration> ... </configuration> </plugin>
Use a Profile
You may want to push the plugin configuration inside a profile. This way you can control when to create the modules folder more easily.
<profiles> <profile> <id>attach</id> <properties> </properties> <build> <plugins> <plugin> <groupId>de.smartics.maven.plugin</groupId> <artifactId>smartics-jboss-modules-maven-plugin</artifactId> <version>2.1.5</version> <executions> <execution> <id>create-modules-archive</id> <goals> <goal>create-modules-archive</goal> </goals> <phase>package</phase> </execution> </executions> <configuration> </configuration> </plugin> </plugins> </build> </profile> </profiles>
An Example Configuration
Here is an short example to get you started:
<profiles> <profile> <id>attach</id> <properties> <attach.archive>true</attach.archive> </properties> <build> <plugins> <plugin> <groupId>de.smartics.maven.plugin</groupId> <artifactId>smartics-jboss-modules-maven-plugin</artifactId> <version>2.1.5</version> <executions> <execution> <id>create-modules-archive</id> <goals> <goal>create-modules-archive</goal> </goals> <phase>package</phase> </execution> </executions> <configuration> <slotStrategy>main</slotStrategy> <defaultSlot>my-product</defaultSlot> <attach>${attach.archive}</attach> <dependencyExcludes> <exclude> <groupId>com.sun</groupId> <artifactId>tools</artifactId> </exclude> <exclude> <groupId>system</groupId> </exclude> </dependencyExcludes> </configuration> </plugin> </plugins> </build> </profile> </profiles>
Module descriptors are stored in XML files that adhere to the smartics JBoss Modules XSD.
Per default they are stored at
src/etc/jboss-modules src/main/config/jboss-modules src/main/resources/META-INF/jboss-modules
The locations to search modules XML documents is configurable via the modules property. Please refer to this property for more information on this topic.
A modules XML looks like this:
<modules xmlns="http://smartics.de/ns/jboss-modules-descriptor/1"> <module name="org.apache.commons.configuration"> <match> <includes> <include> <artifactId>commons-configuration</artifactId> </include> </includes> </match> <apply-to-dependencies> <dependencies> <match> <includes> <include>.+</include> </includes> <excludes> <exclude>org.apache.commons..+</exclude> </excludes> </match> <apply> <export>true</export> </apply> </dependencies> </apply-to-dependencies> </module> <module name="org.apache.commons.$1"> <match> <includes> <include> <artifactId>commons-(.*)</artifactId> </include> </includes> </match> </module> </modules>
The example shows only one module descriptor, but you may add any number of module elements to the list.
Example: Remapping Coordinates
It is also allowed to add different descriptors for the same module. This is e.g. useful to map different artifacts to one module in case you have the same artifact in different versions but also different Maven coordinates. Here is an example:
<modules xmlns="http://smartics.de/ns/jboss-modules-descriptor/1"> <module name="org.javassist"> <match> <includes> <include> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> </include> </includes> </match> <apply-to-module> <dependencies> <module name="javax.api" /> </dependencies> </apply-to-module> </module> <module name="org.javassist"> <directives> <skip>true</skip> </directives> <match> <includes> <include> <groupId>javassist</groupId> <artifactId>javassist</artifactId> </include> </includes> </match> <apply-to-module> <dependencies> <module name="javax.api" /> </dependencies> </apply-to-module> </module> <module name="org.javassist"> <directives> <skip>true</skip> </directives> <match> <includes> <include> <groupId>jboss</groupId> <artifactId>javassist</artifactId> </include> </includes> </match> <apply-to-module> <dependencies> <module name="javax.api" /> </dependencies> </apply-to-module> </module> </modules>
Example: Extensions
If you are writing an extension you might want to add the extension module itself the the main slot, but all its dependencies to a specific slot. Here is the configuration to do this (this example assumes the project coordinates to be de.smartics.jboss.extension:smartics-jboss-counter-extension:1.0
):
<plugin> <groupId>de.smartics.maven.plugin</groupId> <artifactId>smartics-jboss-modules-maven-plugin</artifactId> <version>2.1.5</version> <executions> <execution> <id>create-modules-archive</id> <goals> <goal>create-modules-archive</goal> </goals> <phase>package</phase> </execution> </executions> <configuration> <defaultSlot>other</defaultSlot> </configuration> </plugin>
This configuration states that every dependency encountered should be directed to the slot named other (unless specified otherwise explicitly).
<modules xmlns="http://smartics.de/ns/jboss-modules-descriptor/1"> <module name="$g1.$1" slot="main"> <directives> <inherit-slot>false</inherit-slot> </directives> <match> <includes> <include> <groupId>(de.smartics.jboss.extension)</groupId> <artifactId>(smartics-jboss-counter-extension)</artifactId> </include> </includes> </match> </module> </modules>
The directive inherit-slot is set to false to indicate that the dependencies of this module should go to the default slot. Otherwise all dependencies would go to the slot of its module.
This is the central module.xml
that is generated:
<module xmlns="urn:jboss:module:1.1" name="de.smartics.jboss.extension.smartics-jboss-counter-extension"> <resources> <resource-root path="smartics-jboss-counter-extension-1.0.jar" /> </resources> <dependencies> <module name="de.smartics.util.smartics-jboss-utils" slot="other" /> <module name="de.smartics.util.smartics-validation-utils" slot="other" /> </dependencies> </module>