<build>
<plugins>
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Maven Plugin
To assist in building WildFly Swarm projects, a Maven plugin is available. This plugin creates the -swarm.jar
uberjar which contains your application along with the necessary parts of WildFly to support it.
Configuration
To use the plugin, you must add it to your pom.xml
:
Packaging your application
Default uberjar
To produce the myapp-swarm.jar
, simply perform a typical mvn package
command after setting the package
goal on the plugin:
mvn package
Hollow uberjar
To produce a hollow uberjar, the same mvn package
method is used, but either set the property -Dswarm.hollow=true
or configure
the plugin with <hollow>true</hollow>
from within your pom.xml
.
A hollow uberjar will have the suffix of -hollowswarm.jar
and will not include the actual application deployment. This may be
useful if you are targetting layered Linux containers, where you wish to place the runtime on a lower layer, and the more
frequently changing deployment on a higher layer.
If using the hollow functionality, the command-line arguments to the uberjar shouldl point to one or more deployments that should be used.
java -jar myruntime-hollowjar.jar myapp.war
An example of the hollow jar functionality may be seen in the MicroProfile standalone server.
Running your application
To execute your application, you may use the wildfly-swarm:run
goal:
mvn wildfly-swarm:run
This will execute your application within the WildFly Swarm runtime directly from the Maven command-line, and wait for it to exit.
Both of these goals will perform the same type of fraction detection as the package
task if no WildFly Swarm dependencies are found.
Fraction detection
If the plugin doesn’t detect any WildFly Swarm dependencies in your pom.xml
, it will attempt to auto-detect needed fractions by scanning the application. This is mostly useful for WAR-based applications that you are migrating to WildFly Swarm - you only need to add the plugin to your configuration, and not any other WildFly Swarm dependencies. You can control fraction detection by setting <fractionDetectMode>
. See the configuration options below for more details.
Plugin Configuration Options
The plugin accepts the following options:
Name | Property | Description | Default | Used by |
---|---|---|---|---|
bundleDependencies |
|
If true, dependencies will be included in the -swarm.jar. Otherwise, they will be resolved from |
true |
|
debug |
none |
A port to use for debugging. If set, the swarm process will suspend on start and open a debugger on this port. |
|
|
environment |
none |
A properties-style list of environment variables to use when running the application |
|
|
environmentFile |
|
A |
|
|
fractionDetectMode |
|
The mode for fraction detection. Options are:
* |
|
|
fractions |
none |
A list of extra fractions to include when auto-detection is used, useful for fractions that can’t be detected or user-provided fractions. Each fraction can be of the form |
|
|
hollow |
|
Boolean specifying if the resulting executable jar should be hollow and not include the default deployment. |
|
|
jvmArguments |
|
A list of <jvmArgument> elements specifying additional JVM arguments (such as |
|
|
mainClass |
|
A class to execute as the main |
org.wildfly.swarm.bootstrap.Main |
|
modules |
none |
Paths to a directory containing additional module definitions |
./modules |
|
processes |
none |
Application configurations to start (see multistart section above) |
|
|
properties |
none |
(see properties section below) |
|
|
propertiesFile |
|
(see properties section below) |
|
|
stderrFile |
|
A file path to use to store stderr output instead of sending it stderr of the launching process |
|
|
stdoutFile |
|
A file path to use to store stdout output instead of sending it stdout of the launching process |
|
|
useUberJar |
|
If true, the |
false |
|
Properties
Many properties may be used to configure execution and affect the packaging or running of your application.
If you add a <properties>
or <propertiesFile>
section to the <configuration>
of the plugin, the properties will be used when running your application via mvn wildfly-swarm:run
. Additionally, those same properties will be added to your myapp-swarm.jar
to affect subsequent executions of the uberjar. Any properties loaded from <propertiesFile>
will override same-named properties from <properties>
.
Any properties added to the uberjar can of course be overridden at runtime using the traditional -Dname=value
mechanism of java
.
Only properties specified outside of <properties>
or <propertiesFile>
that start with jboss.
, wildfly.
, swarm.
, or maven.
, or override a property specified in <properties>
or <propertiesFile>
are added to the uberjar at package time.
Please see Configuration Properties for a non-exhaustive list of useful properties.