Search code examples
mavenaemosgi-bundle

Convert non OSGi jars into OSGi bundles as part of Maven build process


In our CQ project we want use some non-osgi jars. Currently we have a separate process other than the build to convert these jars in to OSGi bundles (primarily uses the eclipse plugin project). But is there a perfect way to handle this as part of the Maven build itself? So that the entire process would be transparent to the developers [I have seen some some suggestions for this in some blogs. But this too suggests to create another project for the purpose. Since we are using a multi-module maven structure for the project, is it suggested to add a module just to handle these conversions?].

It would be helpful if you can give me some pointers on this.

Thanks and Regards,

San


Solution

  • You may create a wrapper bundle that includes the non-OSGi JARs as dependencies with the default scope. Then configure the maven-bundle-plugin as follows:

    • non-OSGi dependencies should be marked as embedded,
    • their Java packages should be exported,
    • if the non-OSGi JARs themselves have some dependencies, you can include them as well or mark as ignored.

    All links references a sample pom.xml doing exactly this thing - it wraps the non-OSGi ActiveMQ JAR and its dependencies as an OSGi bundle.