Most of the examples that we have gone through so far have used Apache ant to compile and package JBoss ESB archives. Maven is another very popular build tool. You can use Maven as an alternative to ant to build, compile, and package your archives, and also run your JBoss ESB tests.
The source of JBoss ESB is built with ant
, which means that no list of dependencies for the jbossesb-rosetta.jar
file exists, and this presents a problem for compiling your own custom actions, listeners, and notifiers. The jbossesb-rosetta.jar
file, which contains all the code which you must extend from is not hosted in a public maven repository. In order to be able to compile, you'll have to locate the jbossesb-rosetta.jar
file and treat it as a third-party JAR and install it into your local maven repository manually. This will install it locally, but if you try to build your project on another machine, remember that you will want to install it manually on that machine as well.
Then you'll want to create a pom
for yourself—the following example sets the compiler to JDK 1.5 and includes a number of important dependencies for compiling custom actions. You can use it as an example if you wish to compile your custom actions or gateways inside your Maven build:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <packaging>jar</packaging> <groupId>com.packtpub</groupId> <artifactId>jbossesb-example</artifactId> <version>1.0</version> <name>JBoss ESB Maven Example</name> <description>JBoss ESB Maven Example</description> <url>http://www.packtpub.com/</url> <properties> <jbossesb.version>4.10</jbossesb.version> </properties> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </pluginManagement> <plugins> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.5</version> <scope>test</scope> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>org.jboss.soa.esb</groupId> <artifactId>rosetta</artifactId> <version>4.10</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.14</version> </dependency> </dependencies> </project>
You can use the JBoss packaging plugin to package an ESB archive. The ESB packaging plugin contains a number of configuration options which allow the user to configure the archive name, whether the archive is exploded or not, the locations of the deployment descriptor and deployment file, and what artifacts to include within the archive. Documentation can be found at http://mojo.codehaus.org/jboss-packaging-maven-plugin/esb-mojo.html.
The following is an example of a pom.xml
file using the packaging plugin to package an ESB archive. This example can be used as a template in order to create your own maven pom
files to package your ESB archives.
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <packaging>jboss-esb</packaging> <groupId>com.packtpub</groupId> <artifactId>jbossesb-example</artifactId> <version>1.0</version> <name>JBoss ESB Maven Example</name> <description>JBoss ESB Maven Example</description> <url>http://www.packtpub.com/</url> <properties> <jbossesb.version>4.10</jbossesb.version> </properties> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jboss-packaging-maven-plugin</artifactId> <version>2.2</version> <extensions>true</extensions> <executions> <execution> <id>jboss-esb</id> <phase>package</phase> <goals> <goal>esb</goal> </goals> <configuration> <deploymentDescriptorFile> src/main/resources/META-INF/jboss-esb.xml </deploymentDescriptorFile> <excludeAll>true</excludeAll> </configuration> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.5</version> <scope>test</scope> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> <version>1.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.soa.esb</groupId> <artifactId>rosetta</artifactId> <version>4.10</version> <scope>provided</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.14</version> <scope>provided</scope> </dependency> </dependencies> </project>