The best place to start with the tooling is with the logically lowest component in the JBI spec, which I suppose would be the Shared Library. In essence a shared library is basically a JAR containing a set of JARs and a JBI.xml. The important bits about the Shared Library is that it is named and versioned. This fits nicely with the Maven approach since all Maven artifacts have id's and versions, and also the dependencies within your shared library POM can quickly be used to allow the JBI tooling to create the Shared Libraries zip archive.
In order to convert a standard project to a shared library you simply need to change the packaging (note you will need to have added the plugin repository and plugin from Getting Started).
<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> <groupId>org.apache.servicemix</groupId> <artifactId>MySharedLibrary</artifactId> <packaging>jbi-shared-library</packaging> <version>1.0-SNAPSHOT</version> <name>A custom project</name> ... </project>
Once you have set the packaging to be jbi-shared-library you can run mvn install and you will create both the standard jar packaging which will be set to your repository and also a ZIP packaging which will incorporate your dependencies and also a jbi.xml.
6/23/06 2:47:24 PM EDT: [INFO] ---------------------------------------------------------------------------- 6/23/06 2:47:24 PM EDT: [INFO] Building A custom project 6/23/06 2:47:24 PM EDT: [INFO] task-segment: [install] 6/23/06 2:47:24 PM EDT: [INFO] ---------------------------------------------------------------------------- 6/23/06 2:47:24 PM EDT: [INFO] artifact org.apache.maven.plugins:maven-resources-plugin: checking for updates from central 6/23/06 2:47:25 PM EDT: [INFO] artifact org.apache.maven.plugins:maven-compiler-plugin: checking for updates from central 6/23/06 2:47:26 PM EDT: [INFO] artifact org.apache.maven.plugins:maven-surefire-plugin: checking for updates from central 6/23/06 2:47:27 PM EDT: [INFO] artifact org.apache.maven.plugins:maven-jar-plugin: checking for updates from central 6/23/06 2:47:27 PM EDT: [INFO] artifact org.apache.maven.plugins:maven-install-plugin: checking for updates from central 6/23/06 2:47:30 PM EDT: jbi:generate-jbi-shared-library-descriptor 6/23/06 2:47:30 PM EDT: [INFO] Generating jbi.xml 6/23/06 2:47:30 PM EDT: resources:resources 6/23/06 2:47:30 PM EDT: [INFO] Using default encoding to copy filtered resources. 6/23/06 2:47:31 PM EDT: compiler:compile 6/23/06 2:47:31 PM EDT: [INFO] Nothing to compile - all classes are up to date 6/23/06 2:47:31 PM EDT: resources:testResources 6/23/06 2:47:31 PM EDT: [INFO] Using default encoding to copy filtered resources. 6/23/06 2:47:31 PM EDT: compiler:testCompile 6/23/06 2:47:31 PM EDT: [INFO] No sources to compile 6/23/06 2:47:32 PM EDT: surefire:test 6/23/06 2:47:32 PM EDT: [INFO] No tests to run. 6/23/06 2:47:32 PM EDT: jar:jar 6/23/06 2:47:32 PM EDT: [INFO] Building jar: C:\Workspaces\runtime-New_configuration\MySharedLibrary\target\MySharedLibrary-1.0-SNAPSHOT.jar 6/23/06 2:47:32 PM EDT: jbi:jbi-shared-library 6/23/06 2:47:32 PM EDT: [INFO] Generating shared library C:\Workspaces\runtime-New_configuration\MySharedLibrary\target\MySharedLibrary-1.0-SNAPSHOT.zip 6/23/06 2:47:32 PM EDT: [INFO] Building jar: C:\Workspaces\runtime-New_configuration\MySharedLibrary\target\MySharedLibrary-1.0-SNAPSHOT.zip 6/23/06 2:47:32 PM EDT: install:install 6/23/06 2:47:32 PM EDT: [INFO] Installing C:\Workspaces\runtime-New_configuration\MySharedLibrary\target\MySharedLibrary-1.0-SNAPSHOT.jar to C:\Documents and Settings\pdodds\.m2\repository\org\apache\servicemix\MySharedLibrary\1.0-SNAPSHOT\MySharedLibrary-1.0-SNAPSHOT.jar 6/23/06 2:47:32 PM EDT: [INFO] Installing C:\Workspaces\runtime-New_configuration\MySharedLibrary\target\MySharedLibrary-1.0-SNAPSHOT.zip to C:\Documents and Settings\pdodds\.m2\repository\org\apache\servicemix\MySharedLibrary\1.0-SNAPSHOT\MySharedLibrary-1.0-SNAPSHOT.zip 6/23/06 2:47:32 PM EDT: BUILD SUCCESSFUL
The jbi.xml that was generated will provide for both the Java classes in this project and those in the dependencies to be made available and the shared library name and version will match the Maven pom.xml.
If you have a locally running Apache ServiceMix instance (which its default settings) you can even use the plugin to install the Shared Library by simply typing:
mvn jbi:installSharedLibrary
This will call the ANT tasks from within Maven giving the shared library to install as the one built in the install phase.