h1. Add extended information to bundles
Karaf supports a OSGI-INF/bundle.info file in a bundle.
This file is extended description of the bundle. It supports ASCII character declarations (for adding color, formatting, etc).
For instance, you can define a bundle like this (using Apache Felix maven-bundle-plugin):
{code:lang=xml}
4.0.0
my.groupId
my.bundle
1.0-SNAPSHOT
My Bundle
My bundle short description
${project.basedir}/src/main/resources
true
**/*
org.apache.felix
maven-bundle-plugin
2.2.0
true
${project.artifactId}
...
{code}
And simply add a src/main/resources/OSGI-INF/bundle.info file containing, for instance:
{code}
\u001B[1mSYNOPSIS\u001B[0m
${project.description}
\u001B[1mDESCRIPTION\u001B[0m
Long description of your bundle, including usage, etc.
\u001B[1mSEE ALSO\u001B[0m
\u001B[36mhttp://yourside\u001B[0m
\u001B[36mhttp://yourside/docs\u001B[0m
{code}
You can display this extended information using:
{code}
root@karaf> osgi:info
{code}
h1. Creating bundles for third party dependencies
Karaf supports the wrap: protocol execution.
It allows for directly deploying third party dependencies, like Apache Commons Lang:
{code}
root@karaf> osgi:install wrap:mvn:commons-lang/commons-lang/2.4
{code}
You can specify OSGi statements in the wrap URL:
{code}
root@karaf> osgi:install wrap:mvn:commons-lang/commons-lang/2.4,Bundle-SymbolicName=commons-lang&Bundle-Version=2.4
{code}
You can also create a wrap bundle for a third party dependency.
This bundle is simply a Maven POM that shades an existing jar and package into a jar bundle.
For instance, to create an OSGi bundle that wraps Apache Commons Lang, you can simply define the following Maven POM:
{code:lang=xml}
4.0.0
osgi.commons-lang
osgi.commons-lang
2.4
bundle
commons-lang OSGi Bundle
This OSGi bundle simply wraps commons-lang-2.4.jar artifact.
commons-lang
commons-lang
2.4
true
install
org.apache.maven.plugins
maven-shade-plugin
1.1
package
shade
commons-lang:commons-lang
commons-lang:commons-lang
**
true
true
org.apache.felix
maven-bundle-plugin
2.1.0
true
${project.artifactId}
*
<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))
<_removeheaders>Ignore-Package,Include-Resource,Private-Package,Embed-Dependency
true
{code}
You have now a OSGi bundle for commons-lang that you can deploy directly:
{code}
root@karaf> osgi:install -s mvn:osgi.commons-lang/osgi.commons-lang/2.4
{code}
Some more information is available at [http://gnodet.blogspot.com/2008/09/id-like-to-talk-bit-about-third-party.html], [http://blog.springsource.com/2008/02/18/creating-osgi-bundles/] and [http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html].