WildFly Swarm Uber jar architecture

Overview

WildFly Swarm uber jar is a runable jar generated by wildfly-swarm-plugin, it can be run like

java -jar <myapp>-swarm.jar

This article will cover the content including:

  • How wildfly-swarm-plugin works
  • The architecture of WildFly Swarm Uber jar
  • Some examples

How wildfly-swarm-plugin works

Thw wildfly-swarm-plugin use a BuildTool to a build swarm jar, the BuildTool mainly has 2 aspects task:

  • initialization
  • generate -swarm.jar

initialization

Wildfly swarm build tool init

As above figure, all the following init/set are point to org.wildfly.swarm.tools.BuildTool:

  1. init ProjectAsset - create a projectAsset base on project’s groupId, artifactId, version, packaging type, artfact file, etc.
  2. init fractionList - the fractions predefined by fraction-list project, which contains all wildfly-swarm fractions
  3. init properties - properties passed from mvn build(2 ways to pass properties, one is passed via plugin paramter propertiesFile which point to a properties file, the other is via system properties, note that only properties key start with jboss., swarm., wildfly.)
  4. set main class - main class name come from plugin config
  5. set bundleDependencies - bundleDependencies is a boolean parameter come from plugin config, default is true
  6. set executable - executable is a boolean parameter come from plugin config, default is false
  7. set executableScript - executableScript is a parameter point to a script file come from plugin config
  8. set fractionDetectMode - fractionDetectMode come from plugin config, default value is when_missing
  9. init ArtifactResolvingHelper - a MavenArtifactResolvingHelper be created
  10. set logger - BuildTool.SimpleLogger be create
  11. set additionalFractions - additionalFractions come from plugin config, BuildTool’s fraction method be used to set additionalFractions
  12. set dependency - any dependency of project will be set to BuildTool
  13. set Resources - any resource(src/main/resources) of project will be set to BuildTool
  14. set additionalModules - additionalModules come from plugin config

NOTE: Each init/set reference a method of BuildTool, in every init/set method the rererence attribute of BuildTool be init/set.

generate -swarm.jar

After initialization, BuildTool will generate the -swarm.jar. Before generating the -swarm.jar BuildTool do the following:

  1. analyze Dependencies - rolve all artifact -> scan modules dependencies -> scan bootstrap dependencies -> analyze module dependencies -> analyze provided dependencies
  2. add Wildfly Swarm Bootstrap Jar - move zip Archive(.jar) to a tmpFile -> Detecting fractions -> Adding fractions -> Add bootstrap-VERSION.jar to target Archive
  3. add WildFly Bootstrap Conf - create a META-INF/wildfly-swarm-bootstrap.conf to target Archive, which contain all fractions
  4. add Manifest - add WildFly-Swarm-Main-Class and Main-Class
  5. add WildFly Swarm Properties - add wildfly-swarm.properties to contain all properties
  6. add WildFly Swarm Application Conf - add META-INF/wildfly-swarm-application.conf
  7. add WildFly Swarm Dependencies Conf - add META-INF/wildfly-swarm-dependencies.conf
  8. add Additional Modules
  9. add Project Asset
  10. populate UberJar Maven Repository