Embedding JARs into the OSGi bundle with maven-bundle-plugin

maven-2, osgi

Solution

All the packages that are imported in your classes will be imported by bnd. Perhaps you do not want those packages imported because you know that at runtime you won't be needing them. If you cannot stop bnd from importing them, you can make them optional so that your bundle will still resolve even if they are not supplied by another bundle (at wire time). Try to add this:

<Import-Package>*;resolution:=optional<Import-Package>

To your maven bnd configuration in maven.

Problem

I’m trying to embed some JARs into single OSGi bundle using the feature of maven-bundle-plugin The thing that worries me is that all packages of embedded JARs are put into the Import-Package header of the generated MANIFEST.MF. If I specify explicitly to use only the packages I need, like in the following snippet: ``` Import-Package: org.osgi.framework ``` The build fails with BND error (unresolved references). So, the question here is how can I build the bundle with embedded JARs with "Import-Package" header I need?

Original source