29 September 2013

Using Eclipse plugins in a Equinox - Karaf setup.

Using a modular standard like OSGi promises manny goodies, even the ability the swap out the core implementing the OSGi model and deploying bundles on different OSGi implementations ... but not quite. Every implementation brings in its own background like provisioning, restricting things even more. But now i am getting ahead of myself, back to the beginning.

My main OSGi (development) platform so far is Felix wrapped in a Karaf container backed by Maven for provisioning. Now i had to implement the Open Health Tools Model-Driven Health Tools (MDHT) which, as i was about to find out, is Eclipse based and thus uses the provisioning system called p2.

My first thought was to retrieve all the MDHT sources and convert them to Maven projects, there was even a standalone setup provided which proved functional. Looking into the source i discovered MDHT makes heavy use of the Eclipse Modeling Framework (EMF) and the Eclipse Object Constraint Language (OCL), powerful and non trivial frameworks with a lot of dependencies of their own that are mostly not even Mavenized. The deployment on my favorite OSGi combo was bound to fail, i needed an environment matching that of Eclipse.

Then i remembered that Karaf could swap out Felix, and guess for what: Equinox! Simply edit the etc/config.properties file and modify the karaf.framework property to equinox and finished. This leaves me with the provisioning problem since Karaf has a preference for Maven. Converting the sources myself for such big frameworks is not an option for obvious reasons and after some digging i found myself looking at the Maven website: http://maven.apache.org/plugins/maven-eclipse-plugin/.
MDHT is also a modeling tool for Clinical Document Architecture (CDA) templates based on Eclipse, and thus Equinox, meaning it exists out of Eclipse plugins provisioned by p2.
Using the Maven Eclipse Plugin goal eclipse:to-maven i was able to copy the MDHT Eclipse artifacts out of p2 to my local Maven repository and after a re-indexing by the OSGi Bundle Repository (OBR) i finally could install EMF and OCL on my Equinox - Karaf combo. And of course one can now use the Eclipse artifacts in any Maven project.

More practical experiences are bound to follow.