Monday, October 16, 2017

Wildfly Swarm

"packaging and running Java EE applications by packaging them with just enough of the server runtime to "java -jar" your application."

home page here http://wildfly-swarm.io/

"Stinky Maven" instructions to incorporate the product in your build:



  <wildfly-swarm-version>2017.9.5</wildfly-swarm-version>

  

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.wildfly.swarm</groupId>
        <artifactId>bom-all</artifactId>
        <version>${wildfly-swarm-version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>
  
  
  
      <plugins>
      <plugin>
        <groupId>org.wildfly.swarm</groupId>
        <artifactId>wildfly-swarm-plugin</artifactId>
        <version>${wildfly-swarm-version}</version>
        <executions>
          <execution>
            <goals>
              <goal>package</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <properties>
            <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
          </properties>
        </configuration>
      </plugin>



This will import a BOM in $M2_HOME\repository\org\wildfly\swarm\bom-all\2017.9.5\bom-all-2017.9.5.pom


At this point you simply have to use the Swarm "fractions":

<!-- Wildfly Swarm Camel Fractions -->
    <dependency>
      <groupId>org.wildfly.swarm</groupId>
      <artifactId>camel-cdi</artifactId>
    </dependency>
    <dependency>
      <groupId>org.wildfly.swarm</groupId>
      <artifactId>camel-undertow</artifactId>
    </dependency>
    <!-- Wildfly Swarm Fractions -->
    <dependency>
      <groupId>org.wildfly.swarm</groupId>
      <artifactId>cdi</artifactId>
    </dependency>



each of these fractions will simply consist of a JAR with a module.xml, this one is for the camel-cdi fraction:


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<module xmlns="urn:jboss:module:1.3" name="org.apache.camel.component.cdi">
<resources>
  <artifact name="org.apache.camel:camel-cdi:2.19.0"/>
  </resources>
  <dependencies>
  <module name="javax.annotation.api"/>
    <module name="javax.enterprise.api"/>
    <module name="javax.xml.bind.api"/>
    <module name="org.apache.camel.core.xml"/>
    <module name="org.jboss.weld.core"/>
    <module name="org.jboss.weld.spi"/>
    <module name="org.slf4j"/>
    <module name="javax.el.api"/>
    <module name="org.apache.camel.core"/>
  </dependencies>
</module>




All this looks like Matrovshka матрёшка ...




This page is similar to the Spring Initializr http://wildfly-swarm.io/generator/

To add health monitoring, follow these instructions https://wildfly-swarm.gitbooks.io/wildfly-swarm-users-guide/advanced/monitoring.html

important commands

mvn wildfly-swarm:run

or
mvn package
cd target
java -jar demo-swarm.jar demo.war


if you add

<plugin>
 <groupId>org.wildfly.plugins</groupId>
 <artifactId>wildfly-maven-plugin</artifactId>
 <version>1.2.1.Final</version>
</plugin>

you can also do:

mvn wildfly:deploy



No comments: