Fabric3 Gradle Assembly Plugin

The Fabric3 Gradle assembly plugin is used to create a runtime image as part of an automated, reproducible build process. The plugin downloads the Fabric3 standalone runtime as well as required profiles, extensions and application contributions. In addition, it can apply custom configuration to the runtime image. The assembly plugin will use these artifacts to create a runtime distribution complete with installed application contributions. During the release process, the runtime image can be uploaded to a repository where it can be accessed by IT automation software during the system packaging and deployment process.

Plugin Setup

When executed, the Fabric3 assembly plugin will place the resulting runtime image in the project.build.directory/image directory.  The following demonstrates how to configure the assembly plugin:

apply plugin: 'fabric3-assembly'

buildscript {
    dependencies {
        classpath group: 'org.fabric3.gradle', name: 'fabric3-assembly', version: fabric3Version
    }
}
 
fabric3Assembly {
    // Configure the runtime with profiles
    profile group: 'org.fabric3', name: 'profile-timer', version: fabric3Version

	// include project contributions
	contribution project('...')
	contribution project('...')
 
    // Overlay the standard runtime configuration with a the selected one for the current profile
    configFile source: 'src/main/config/' + activeProfile + '/systemConfig.xml'
    if (activeProfile == 'production') {
        configFile source: 'src/main/datasource/ojdbc6.jar', target: 'extensions/datasource'
    } else {
        configFile source: 'src/main/datasource/h2-1.3.175.jar', target: 'extensions/datasource'
        contribution project(':modules:setup:setup-test')
    }

    // Remove standard runtime configurations other than the default VM configuration (i.e. controller, participant, node)
    clean true
}

The above configuration installs the Fabric3 timer profile as part of the runtime image. In addition, it copies the runtime configuration (systemConfig.xml) based on the active profile, for example, if a test or production is image is being built. Further, it demonstrates installing datasources (and JDBC drivers) and an additional setup module ('setup-test') based on the active build profile.

Configuration Elements

The following configuration elements are supported by the plugin:

  • contribution - points to a Project in the current build or external dependency using the Gradle dependency format
  • configFile source: <>, target:<> - a file that is copied from the source to target location relative to the runtime image root directory
  • profile - points to a Fabric3 profile specified using the Gradle dependency format   
  • extension -  points to a Fabric3 extension specified using the Gradle dependency format   
  • exclude - excludes an extension module that is either a dependency of a profile or extension
  • datasources - Points to a JDBC module (e.g. JAR) resolved as a dependency. Specified using the Gradle dependency format.
  • shared - Adds a module to the runtime shared classpath. Specified using the Gradle dependency format. 
  • contributionTarget <name> - The runtime name. All configuration will be targeted to <runtime image>/runtimes/<runtime name>.
  • clean true|false - If true, removes runtime configuration other than the contributionTarget.