<plugins>
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
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
To produce the myapp-swarm.jar
, simply perform a typical mvn package
command after setting the package
goal on the plugin:
mvn package
Example
<plugins>
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
<configuration>
<bundleDependencies>false</bundleDependencies>
<properties>
<swarm.bind.address>127.0.0.1</swarm.bind.address>
</properties>
</configuration>
</plugin>
</plugins>
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. If you want to start the application without maven waiting for it to exit, use the wildfly-swarm:start
goal.
Starting multiple applications at once
You can start multiple swarm applications at once using the wildfly-swarm:multistart
goal (this is useful for integration testing a set of applications). Each application is specified as a <process>
containing an optional <groupId>
, an <artifactId>
, and an optional <executionId>
(useful if you need to launch multiple copies of the same application). Each <process>
can also include any configuration that is valid for the wildfly-swarm:start
goal.
Example
<plugins>
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<executions>
<execution>
<id>multistart</id>
<phase>pre-integration-test</phase>
<goals>
<goal>multistart</goal>
</goals>
<configuration>
<processes>
<process>
<artifactId>my-frontend-app</artifactId>
</process>
<process>
<artifactId>my-auth-app</artifactId>
<properties>
<swarm.http.port>8081</swarm.http.port>
</properties>
<mainClass>com.example.auth.Main</mainClass>
</process>
<process>
<artifactId>my-indexing-app</artifactId>
<properties>
<swarm.http.port>8082</swarm.http.port>
</properties>
<environment>
<ENV>test</ENV>
</environment>
</process>
</processes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Stopping started applications
If you have started any applications with either wildfly-swarm:start
or wildfly-swarm:multistart
, they can be stopped by executing the wildfly-swarm:stop
goal.
Configuration Options
The plugin accepts the following options:
Name | Description | Default | Used by |
---|---|---|---|
bundleDependencies |
If true, dependencies will be included in the -swarm.jar. Otherwise, they will be resolved from |
true |
|
debug |
A port to use for debugging. If set, the swarm process will suspend on start and open a debugger on this port. |
|
|
environment |
A properties-style list of environment variables to use when running the application |
|
|
environmentFile |
A |
|
|
mainClass |
A class to execute as the main |
org.wildfly.swarm.bootstrap.Main |
|
modules |
Paths to a directory containing additional module definitions |
./modules |
|
processes |
Application configurations to start (see multistart section above) |
|
|
properties |
(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 configuration execution and affect the packaging or running of your application.
By adding 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.
Useful properties include, but are not limited to:
Name | Description | Default |
---|---|---|
swarm.bind.address |
Interface to bind servers |
0.0.0.0 |
swarm.http.port |
Sets the port for the HTTP server |
8080 |
swarm.https.port |
Sets the port for the HTTPS server |
8443 |
swarm.port.offset |
Sets a global port adjustment |
0 |
swarm.context.path |
Sets the context path for the deployed application |
/ |
swarm.export.deployment |
Causes a deployed artifact to be dumped to disk when swarm starts, for debugging |
false |
swarm.debug.port |
If provided, the swarm process will pause for debugging on the given port |