Converting JAR file to OSGI Bundle
You are reading this post, becasue you googled for OSGI bundle which you included in your pom dependency, but unfortunately you did not find OSGI bundle but ended with simple jar file only. So, in this post, I would like to put in short, how to convert JAR file to OSGI bundle.
1. Create a maven project in eclipse.
- When creating, you need to be aware of what will go in artifact Id and group id.
- Use same groupId and change artifact Id to
-osgi. offcourse, you can follow any naming convention, but never give same name as dependency you are adding.(Giving the same name as dependent bundle will not export packages and treats output of this project(osgi bundle) and dependent bundle(jar) as same). Be carefull here.
4. Build project with "mvn clean install" from command prompt.
5. Varify the "Export-Package:" section of MANIFEST.MF file, which should list all the packages which are there in your(added dependency) jar file.
6. New bundle is ready to deploy to OSGI container like sling(Felix console).
In above step 2, as we are specifying, which unpacks all classes under dependent bundles, and "maven-bundle-plugin" plugin is responsible to create osgi bundle including these dependent classes.
You can optionaly exclude some of the packages and have some custom classes and include those classes to this bundle as well by having
, and tags under tags under of this bundle. One more last thing, you can also combine multiple jars by adding maven dependecy to pom.xml file and build single OSGI bundle. This will help to reduce the pain of deploying individual bundles to felix console. Offcourse you have to build this bundle agin if you would like to change any of the dependent jars bundle version. Hope this helps and happy OSGIfying...:-) References: http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html