Reputation: 1929
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
Upvotes: 0
Views: 4462
Reputation: 103
You could automatically wrap non-OSGi jars into OSGi bundles using the p2-maven-plugin. It will create a valid P2 repository from your jars. The only drawback is, that you have to call maven twice: first to create the repo and then to use it. The plugin can be found here: https://github.com/reficio/p2-maven-plugin
Upvotes: 4
Reputation: 869
A good reference pom.xml: https://github.com/Adobe-Consulting-Services/com.adobe.acs.bundles.twitter4j/blob/master/bundle/pom.xml
The link above wraps twitter4j jar into an osgi bundle. Checks twice what you export and not export any unnecessary packages.
If you want to embed a taglib or need to embed META-INF folder too, see the link below as an example: https://github.com/apache/sling/blob/trunk/bundles/scripting/jsp-jstl/pom.xml
Some jars are also OSGi bundles, so before you wrap it, download it from maven central and check the MANIFEST.MF file inside the jar file.
Upvotes: 2
Reputation: 9304
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:
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.
Upvotes: 11