Creating a target eclipse platform and bundling non-osgi bundles on the fly
One challenge even in eclipse 3.5 is managing the target platform for your eclipse RCP. It turns out that while many enterprise level bundles are already OSGi ready, many are not. If you want to create a target platform more easily, and have an automated build facility that does not require manual conversion of non-OSGi bundles, you need to create process to build the target platform with your 3rd party bundles.
The idea is very similar to what is described in this blog http://springosgi.googlepages.com/ where a target platform is built for a spring dm (spring dynamic modules) environment. Follow the instructions at http://springosgi.googlepages.com/ch01.html carefully. But the question is, if you have non-OSGi bundles, what do you do? Can you automate the process?
Lets assume that you have a bundle that should be in the target but is not OSGi. I’ll use miglayout-3.7-swt.jar as an example.
Prepare Your Eclipse Environment
Install m2eclipse, http://docs.codehaus.org/display/M2ECLIPSE/Home.
This will implement the maven functionality to manage dependencies. This should have be installed if you followed the instructions on the blog.
Enhance Your pom.xml
First, add the following repository to your pom file:
Then add the following plugin to your pom.xml:
And within that plugin definition, you can have multiple execution entries:
Here we have assumed that the folder called jars holds the non-OSGi jars. Maven could also download those to the jars directory as well but you could just copy them to that special directory.
You’ll need a template.mf as well and it will find the default although I set it explicitly in the pom.xml. Don’t forget that the template is extremely sensitive to spaces after the colons (:), you need to have a space.
Run Maven Packaging
The use the right mouse button context menu to RunAs: Maven Packaging. This builds your target definition. Don’t forget to reload the target platform definition in Windows>Preferences>PDE>Target Platform to ensure that it has all the plugins that were downloaded or were created. You can also stick in other headers inside the POM for the manifest, such as Eclipse-BuddyPolicy: Registered.