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
As above figure, all the following init/set are point to org.wildfly.swarm.tools.BuildTool
:
- init ProjectAsset - create a projectAsset base on project’s groupId, artifactId, version, packaging type, artfact file, etc.
- init fractionList - the fractions predefined by fraction-list project, which contains all wildfly-swarm fractions
- 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 withjboss.
,swarm.
,wildfly.
) - set main class - main class name come from plugin config
- set bundleDependencies - bundleDependencies is a boolean parameter come from plugin config, default is true
- set executable - executable is a boolean parameter come from plugin config, default is false
- set executableScript - executableScript is a parameter point to a script file come from plugin config
- set fractionDetectMode - fractionDetectMode come from plugin config, default value is when_missing
- init ArtifactResolvingHelper - a MavenArtifactResolvingHelper be created
- set logger - BuildTool.SimpleLogger be create
- set additionalFractions - additionalFractions come from plugin config, BuildTool’s fraction method be used to set additionalFractions
- set dependency - any dependency of project will be set to BuildTool
- set Resources - any resource(src/main/resources) of project will be set to BuildTool
- 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:
- analyze Dependencies - rolve all artifact -> scan modules dependencies -> scan bootstrap dependencies -> analyze module dependencies -> analyze provided dependencies
- add Wildfly Swarm Bootstrap Jar - move zip Archive(
.jar) to a tmpFile -> Detecting fractions -> Adding fractions -> Add bootstrap-VERSION.jar to target Archive - add WildFly Bootstrap Conf - create a
META-INF/wildfly-swarm-bootstrap.conf
to target Archive, which contain all fractions - add Manifest - add WildFly-Swarm-Main-Class and Main-Class
- add WildFly Swarm Properties - add
wildfly-swarm.properties
to contain all properties - add WildFly Swarm Application Conf - add
META-INF/wildfly-swarm-application.conf
- add WildFly Swarm Dependencies Conf - add
META-INF/wildfly-swarm-dependencies.conf
- add Additional Modules
- add Project Asset
- populate UberJar Maven Repository