When it is not a bundle?

Although Maven Central now provides the majority of bundles with OSGi metadata, there are still a lot of JARs out there without. Although these JARs are not useful in an OSGi framework, they can be used as first class citizens in Bndtools.

When you use the Maven Bnd Repository you can add any coordinate as a dependency. Where a Maven coordinate has the syntax:

groupid ':' artifactid ( ':' extension ( ': classifier )? )? ':' version

In the Repositories view this will show up as the dreaded [!] Not a bundle when there is no OSGi metadata. However, you can still use this as a normal bundle in any place you can use a path, like -buildpath, -testpath, -runbundles, etc. The trick is to use the groupid:artifactid` as the bundle symbolic name. The Maven Bnd Repository recognizes this and will use the Maven metadata to provide bnd with the available versions.

For example:

    -buildpath:  \
       osgi.annotation, \
       org.apache.mina:mina-core

When you do not provide a version, bnd will select the lowest version for compilation and the highest version for running.

2 Likes

Could you elaborate a bit more on when to and when not to this?
Are you referring to use-cases where you create own wrapper-bundles to OSGIfy a non-OSGI jar?

It is used in wrapping JARs, ‘borrowing’ a number of packages, or on the -testpath.