Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

Plugin Setup

The excerpt shows the basic plugin setup in a Maven POM fileWhen executed, the Fabric3 assembly plugin will place the resulting runtime image in the project.build.directory/image directory. The Fabric3 assembly plugin is typically used in conjunction with the Maven assembly plugin to produce a compressed archive. This can be done as follows:

Code Block
xml
xml
<plugins>
    <plugin>
        <groupId>org.codehaus.fabric3</groupId>
        <artifactId>fabric3-assembly-plugin</artifactId>
        <version>${fabric3.version}</version>
        <executions>
            <execution>
                <id>fabric3-assembly</id>
                <goals>
                    <goal>fabric3-assembly</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <runtimeVersion>${fabric3.version}</runtimeVersion>
			<contributions>
                 <dependency>
                    <groupId>org.fabric3.samples</groupId>
                    <artifactId>gateway</artifactId>
                    <version>${app.version}</version>
				</dependency>
			<contributions>
        </configuration>
    </plugin>
</plugins> 

The above excerpt will create a runtime image with one installed application contribution. When executed, the plugin will place the resulting runtime image in the project.build.directory/image directory. The Fabric3 assembly plugin is typically used in conjunction with the Maven assembly plugin to produce a compressed archive. This can be done as follows:

Code Block
xmlxml
<plugins>     <plugin>
        <groupId>org.codehaus.fabric3</groupId>
        <artifactId>fabric3<artifactId>maven-assembly-plugin</artifactId>
        <version>${fabric3assembly.version}</version>
        <executions>
            <execution>
                <id>fabric3<id>make-assembly</id>
                <phase>package</phase>
                <goals>
                    <goal>fabric3-assembly<<goal>single</goal>
                </goals>
             </execution>
        </executions>
    </plugin>
</plugins>

The Maven assembly.xml will then compress the runtime image into a ZIP file:

Code Block
languagehtml/xml
<assembly ....>
<configuration>    <id>bin</id>
        <runtimeVersion>${fabric3.version<baseDirectory>${project.build.directory}</runtimeVersion>baseDirectory>
			<contributions>    <formats>
        <format>zip</format>
    <dependency></formats>
    <fileSets>
        <fileSet>
      <groupId>org.fabric3.samples</groupId>      <outputDirectory>/</outputDirectory>
              <artifactId>gateway</artifactId><directory>${project.build.directory}/image</directory>
               </fileSet>
    <version>${app.version}</version>fileSets>
				</dependency>
			<contributions>
        </configuration>
    </plugin></assembly> 

Adding Contributions

Contributions are added using the contributions element of the plugin configuration as shown in the previous example. Note that the order of the contributions is not important: at startup, Fabric3 will introspect and order the contributions based on declared dependencies such as Java package imports (for details of dependency ordering, see Contribution Modularity). 


Adding Configuration

 Typically you will need to add runtime configuration to the produced image. This can be done by creating a systemConfig.xml file in the Maven module source directory and including it in the plugin configuration under configurationFiles:

Code Block
xml
xml
<plugins>
    <plugin>
        <groupId>org.codehaus.fabric3</groupId>
    <plugin>         <artifactId>maven<artifactId>fabric3-assembly-plugin</artifactId>
        <version>${assemblyfabric3.version}</version>
        .....
    <executions>    <configuration>
            <execution><runtimeVersion>${fabric3.version}</runtimeVersion>
            <configurationFiles>
   <id>make-assembly</id>             <copy>
   <phase>package</phase>                 <goals><source>../../../config/security.xml</source>
                    <goal>single</goal><destination>runtimes/vm/config</destination>
                </goals>copy>
             </execution>configurationFiles>
        </executions>configuration>
    </plugin>
</plugins>

The Maven assembly.xml will then compress the runtime image into a ZIP file:

<assembly ....>
Code Block
languagehtml/xml
Info

When creating a production system remember to disable the contribution directory scanner in systemConfig.xml by declaring a production runtime:

Code Block
<config>
   
<id>bin</id>
 
<baseDirectory>${project.build
.
directory}</baseDirectory> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <outputDirectory>/</outputDirectory> <directory>${project
.
build
.
directory}/image</directory>

    
</fileSet> </fileSets> </assembly> 

Adding Contributions

-->disable scan directory

Adding Configuration

<scanner production="true"/>
</config>

 

Adding Profiles

 

Adding Extensions

...

Code Block
xml
xml
<plugins>
    <plugin>
        <groupId>org.codehaus.fabric3</groupId>
        <artifactId>fabric3-assembly-plugin</artifactId>
        <version>${fabric3.version}</version>
        <executions>
            <execution>
                <id>fabric3-assembly</id>
                <goals>
                    <goal>fabric3-assembly</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <runtimeVersion>${fabric3.version}</runtimeVersion>
            <profiles>
                <!-- JMS support -->
                <profile>
                    <groupId>org.codehaus.fabric3</groupId>
                    <artifactId>profile-jms</artifactId>
                    <version>${fabric3.version}</version>
                </profile>
                <!-- JAX-RS support -->
                <profile>
                    <groupId>org.codehaus.fabric3</groupId>
                    <artifactId>profile-rs</artifactId>
                    <version>${fabric3.version}</version>
                </profile>
            </profiles>
            <!-- add contributions -->
			<contributions>
                 <dependency>
                    <groupId>org.fabric3.samples</groupId>
                    <artifactId>gateway</artifactId>
                    <version>${app.version}</version>
				</dependency>
				<dependency>
                    <groupId>org.fabric3.samples</groupId>
                    <artifactId>backend</artifactId>
                    <version>${app.version}</version>
				</dependency>
			</contributions>
            <!-- overlay configuration -->
            <configurationFiles>
                <copy>
                    <source>../../../config/security.xml</source>
                    <destination>runtimes/vm/config</destination>
                </copy>
            </configurationFiles>
        </configuration>
    </plugin>
</plugins>