Converting simple jars into OSGI bundles

If for some reason you are working with OSGI, at some point you’ll probably need to use 3rd party dependencies to complete your job, unfortunately, not all of those dependencies are built with OSGI in mind.

Sometimes it’s easy some aren’t, for example, when the package creator ignores good practices and creates classes with no packages (in the root of the project/package), then we have to deal with this before converting the package into OSGI.

1# Converting into OSGI

For this task, we can benefit of the maven-bundle-plugin that set the necessary properties into META-INF/MANIFEST.MF file, making it OSGI compatible.

2# Avoiding the root classes problem or “The default package ‘.’ is not permitted by the Import-Package syntax”

To do that and skip classes without any package, you can use the instructions section to export just the packages you need to complete your job.

Following you can see a sample of how to fix those 2 problems, I hope it can be useful to you 😉

Leave a Reply