LibraryToggle FramesPrintFeedback

A Maven project for building an OSGi bundle can be a simple single level project. It does not require any sub-projects. However, it does require that you do the following:

  1. Add the bundle plug-in to your POM.

  2. Instruct Maven to package the results as an OSGi bundle.


There are several Maven archetypes you can use to set up your project with the appropriate settings.

Before you can use the bundle plug-in you must add a dependency on Apache Felix. After you add the dependency, you can add the bundle plug-in to the plug-in portion of the POM.

Example B.1 shows the POM entries required to add the bundle plug-in to your project.

Example B.1. Adding an OSGi bundle plug-in to a POM

  <dependency> 1
    <plugin> 2
          <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName> 3
          <Import-Package>*,org.apache.camel.osgi</Import-Package> 4
          <Private-Package>org.apache.servicemix.examples.camel</Private-Package> 5

The entries in Example B.1 do the following:


Adds the dependency on Apache Felix


Adds the bundle plug-in to your project


Configures the plug-in to use the project's artifact ID as the bundle's symbolic name


Configures the plug-in to include all Java packages imported by the bundled classes; also imports the org.apache.camel.osgi package


Configures the plug-in to bundle the listed class, but not to include them in the list of exported packages


Edit the configuration to meet the requirements of your project.

For more information on configuring the bundle plug-in, see Configuring the Bundle Plug-In.

Comments powered by Disqus
loading table of contents...