Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

maven-2

osgi

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?

like image 842
Ivan Dubrov Avatar asked Sep 04 '09 10:09

Ivan Dubrov


People also ask

What does maven Bundle plugin do?

The maven-bundle-plugin provides a simple goal to check for missing bundles, and remove them from the local OBR. Configuration: obrRepository path to local OBR, defaults to <local-maven-repository> /repository.

What is an OSGi bundle?

OSGi is a Java framework for developing and deploying modular software programs and libraries. Each bundle is a tightly coupled, dynamically loadable collection of classes, jars, and configuration files that explicitly declare their external dependencies (if any).

What is difference between jar and bundle?

There is basically no difference. A JAR is a bundle and a bundle is a JAR, the formats are identical. However, a useful bundle requires OSGi metadata in its manifest so that an OSGi framework can manage the visibility of classes between bundles.


1 Answers

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.

like image 163
omerkudat Avatar answered Oct 05 '22 03:10

omerkudat