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):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>my.groupId</groupId>
 <artifactId>my.bundle</artifactId>
 <version>1.0-SNAPSHOT</version>
 <name>My Bundle</name>
 <description>My bundle short description</description>
 <build>
 <resources>
 <resource>
 <directory>/x1/asf/karaf-2.3.x/target/checkout/manual/src/main/resources</directory>
 <filtering>true</filtering>
 <includes>
 <include>**/*</include>
 </includes>
 </resource>
 </resources>
 <plugins>
 <plugin>
 <groupId>org.apache.felix</groupId>
 <artifactId>maven-bundle-plugin</artifactId>
 <version>2.2.0</version>
 <extensions>true</extensions>
 <configuration>
 <instructions>
 <Bundle-SymbolicName>manual</Bundle-SymbolicName>
 ...
 </instructions>
 </configuration>
 </plugin>
 </plugins>
 </build>
</project>

And simply add a src/main/resources/OSGI-INF/bundle.info file containing, for instance:

\u001B[1mSYNOPSIS\u001B[0m
 The Apache Software Foundation provides support for the Apache community of open-source software projects.
 The Apache projects are characterized by a collaborative, consensus based development process, an open and
 pragmatic software license, and a desire to create high quality software that leads the way in its field.
 We consider ourselves not simply a group of projects sharing a server, but rather a community of developers
 and users.
\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

You can display this extended information using:

root@karaf> osgi:info

Creating bundles for third party dependencies

Karaf supports the wrap: protocol execution.

It allows for directly deploying third party dependencies, like Apache Commons Lang:

root@karaf> osgi:install wrap:mvn:commons-lang/commons-lang/2.4

You can specify OSGi statements in the wrap URL:

from the shell

root@karaf> osgi:install -s 'wrap:mvn:commons-lang/commons-lang/2.4$Bundle-SymbolicName=commons-lang&Bundle-Version=2.4'

from features.xml

<bundle>wrap:mvn:commons-lang/commons-lang/2.4$Bundle-SymbolicName=commons-lang&undle-Version=2.4</bundle>

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:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>osgi.commons-lang</groupId>
 <artifactId>osgi.commons-lang</artifactId>
 <version>2.4</version>
 <packaging>bundle</packaging>
 <name>commons-lang OSGi Bundle</name>
 <description>This OSGi bundle simply wraps commons-lang-2.4.jar artifact.</description>
 <dependencies>
 <dependency>
 <groupId>commons-lang</groupId>
 <artifactId>commons-lang</artifactId>
 <version>2.4</version>
 <optional>true</optional>
 </dependency>
 </dependencies>
 <build>
 <defaultGoal>install</defaultGoal>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-shade-plugin</artifactId>
 <version>1.1</version>
 <executions>
 <execution>
 <phase>package</phase>
 <goals>
 <goal>shade</goal>
 </goals>
 <configuration>
 <artifactSet>
 <includes>
 <include>commons-lang:commons-lang</include>
 </includes>
 </artifactSet>
 <filters>
 <filter>
 <artifact>commons-lang:commons-lang</artifact>
 <excludes>
 <exclude>**</exclude>
 </excludes>
 </filter>
 </filters>
 <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
 <createDependencyReducedPom>true</createDependencyReducedPom>
 </configuration>
 </execution>
 </executions>
 </plugin>
 <plugin>
 <groupId>org.apache.felix</groupId>
 <artifactId>maven-bundle-plugin</artifactId>
 <version>2.1.0</version>
 <extensions>true</extensions>
 <configuration>
 <instructions>
 <Bundle-SymbolicName>manual</Bundle-SymbolicName>
 <Export-Package>*</Export-Package>
 <Import-Package></Import-Package>
 <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
 <_removeheaders>Ignore-Package,Include-Resource,Private-Package,Embed-Dependency</_removeheaders>
 </instructions>
 <unpackBundle>true</unpackBundle>
 </configuration>
 </plugin>
 </build>
</project>

You have now a OSGi bundle for commons-lang that you can deploy directly:

root@karaf> osgi:install -s mvn:osgi.commons-lang/osgi.commons-lang/2.4

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.

AltStyle によって変換されたページ (->オリジナル) /