...
Using a Maven archetype, we will create a simple project whose job is to simply bundle up other project. Below is the command to create the SA Maven project:
Panelnoformat |
---|
$ mvn archetype:create \ -DarchetypeGroupId=org.apache.servicemix.tooling \ -DarchetypeArtifactId=servicemix-service-assembly \ -DarchetypeVersion=3.1-incubating \ -DgroupId=com.mycompany \ -DartifactId=my-sa \ -DremoteRepositories=http://people.apache.org/repo/m2-incubating-repository ![]()
|
The command above utilizes the servicemix-service-assembly Maven archetype to create a Maven project named my-sa. This command creates a directory named my-sa
that contains a Maven project skeleton meaning all the necessary files are in place, you simply need to enter the correct values for the configuration. Below is the directory structure created by this archetype:
Panelnoformat |
---|
./pom.xml |
The only thing that is necessary in a SA Maven project is a the Maven pom.xml
file. The pom.xml
contains the necessary Maven JBI plugin configuration. This is a plugin that automatically generates the META-INF/jbi.xml
file based on other information in the pom.xml
file. The only thing you need to do is specify which SUs will be included in this SA.
...
In order to actually include SUs inside of the SA, all you need to do is list the SUs as dependencies in the pom.xml
file. Below is an example of including the my-consumer-su SU inside this SA:
Code Block | ||
---|---|---|
| ||
<dependencies> <dependency> <groupId>com.mycompany</groupId> <artifactId>my-consumer-su</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> |
This information was gleaned from the my-consumer-su pom.xml
file in the What is a JBI SU and how do I create one? FAQ entry. Now that we have a SU listed as a dependency, it's time to build and package the SA. Below is the Maven command to do this:
Panelnoformat |
---|
$ mvn install |
You will need to have Maven 2.0.4 or higher installed in order to run this command. This packages up the my-consumer-su SU inside of the my-sa SA and places the my-sa build artifact in the target directory.
...
There are only two requirements of a JBI SA - that it contain a JBI deployment descriptor located in META-INF/jbi.xml
and that it contain at least one SU. Below is the hierarchy of the contents of the SU archive that is created when running the Maven install goal as noted above:
Code Blocknoformat |
---|
$ jar tvf ./target/my-sa-1.0-SNAPSHOT.jar 0 Wed Mar 28 21:10:02 MDT 2007 META-INF/ 126 Wed Mar 28 21:10:00 MDT 2007 META-INF/MANIFEST.MF 596 Wed Mar 28 21:10:00 MDT 2007 META-INF/jbi.xml 3391 Wed Mar 28 21:10:00 MDT 2007 my-consumer-su-1.0-SNAPSHOT.zip 0 Wed Mar 28 21:10:02 MDT 2007 META-INF/maven/ 0 Wed Mar 28 21:10:02 MDT 2007 META-INF/maven/com.mycompany/ 0 Wed Mar 28 21:10:02 MDT 2007 META-INF/maven/com.mycompany/my-sa/ 2461 Wed Mar 28 21:09:44 MDT 2007 META-INF/maven/com.mycompany/my-sa/pom.xml 110 Wed Mar 28 21:10:00 MDT 2007 META-INF/maven/com.mycompany/my-sa/pom.properties |
Notice that the SA archive contains not only the required META-INF/jbi.xml
file, but also the included my-consumer-su-1.0-SNAPSHOT.zip
file. The META-INF/jbi.xml
file was generated by the JBI Maven plugin. Below is the contents of this file:
Code Blocknoformat |
---|
$ cat ./target/my-sa-1.0-SNAPSHOT-installer/META-INF/jbi.xml <?xml version="1.0" encoding="UTF-8"?> <jbi xmlns="http://java.sun.com/xml/ns/jbi" version="1.0"> <service-assembly> <identification> <name>my-sa</name> <description>A custom project</description> </identification> <service-unit> <identification> <name>my-consumer-su</name> <description>my-consumer-su</description> </identification> <target> <artifacts-zip>my-consumer-su-1.0-SNAPSHOT.zip</artifacts-zip> <component-name>servicemix-http</component-name> </target> </service-unit> </service-assembly> |
...