Gradle Plugin

To assist in building WildFly Swarm projects, a Gradle plugin is available. This plugin creates the -swarm.jar uberjar which contains your application along with the necessary parts of WildFly to support it.

Note
Gradle doesn’t get the same attention by the core developers as maven. If you wan’t to be on the safe side, use maven. If you are interested in contributing to the gradle build system, please let use now!

Packaging your application

To use the plugin, you must add it to your build.gradle:

buildscript {
  repositories {
    mavenLocal()
    mavenCentral()
  }

  dependencies {
    classpath "org.wildfly.swarm:wildfly-swarm-plugin:1.0.0.Alpha9-SNAPSHOT"
  }
}

apply plugin: 'wildfly-swarm'

To produce the myapp-swarm.jar, simply perform a gradle wildfly-swarm-package command after adding the plugin.

Using the WildFly Swarm BOM

WildFly Swarm provides a BOM that specifies the versions for all of the provided fractions. To import it into your gradle build, you’ll need to use the dependency-management-plugin:

buildscript {
  repositories {
    mavenLocal()
    mavenCentral()
  }

  dependencies {
    classpath "io.spring.gradle:dependency-management-plugin:0.5.6.RELEASE"
    classpath "org.wildfly.swarm:wildfly-swarm-plugin:1.0.0.Alpha9-SNAPSHOT"
  }
}

apply plugin: "io.spring.dependency-management"
apply plugin: 'wildfly-swarm'


dependencyManagement {
  imports {
    mavenBom "org.wildfly.swarm:bom:1.0.0.Alpha9-SNAPSHOT"
  }
}

dependencies {
  compile "org.wildfly.swarm:jaxrs"
}

Configuration

You can optionally provide configuration to the plugin.

Configuration Options

The plugin accepts the following options:

Name Description Default

bundleDependencies

If true, dependencies will be included in the -swarm.jar. Otherwise, they will be resolved from $M2_REPO or the network.

true

mainClassName

A class to execute as the main. If not set, the plugin will check for mainClassName from the application plugin before using the default.

org.wildfly.swarm.bootstrap.Main

modules

Paths to a directory containing additional module definitions

./modules

properties

(see properties section below)

propertiesFile

(see properties section below)

archiveTask

A Jar-Task which should be wrapped instead of the JAR-Task (Java-Plugin) or WAR-Task (WAR-Plugin)

Properties

Many properties may be used to configure execution and affect the packaging or running of your application.

If you set a properties map or the propertiesFile field in the swarm block in your build script, the 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., or swarm., 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.

Example

swarm {
  properties {
    swarm.http.port = 8181
    my.app.property = 'biscuits'
  }

  bundleDependencies = false
  moduleDirs = [new File(buildDir, 'resources/main/modules')]
  propertiesFile = new File(buildDir, "resources/main/some.properties")
}