WAR Packaging

If you have an existing WAR-based application, you can construct a self-contained myapp-swarm.jar from it with ease. By using the plugin of your choice (Maven or Gradle), the resulting uberjar will contain your application along with enough of the application-server to support it.

Maven

For a Maven project, you already have a pom.xml with

<packaging>war</packaging>

Simply add configuration for the wildfly-swarm-plugin:

<build>
  <plugins>
    <plugin>
      <groupId>org.wildfly.swarm</groupId>
      <artifactId>wildfly-swarm-plugin</artifactId>
    </plugin>
  </plugins>
</build>

When you perform a typical Maven build using mvn package, your target directory will include a myapp-swarm.jar version of your application.

If you don’t specify any WildFly Swarm fractions as dependencies, the maven plugin will auto-detect the fractions your application needs. See the Maven chapter for more details.

This artifact can then be executed using:

java -jar ./target/myapp-swarm.jar