Creating an OSGi bundle with Maven

This article explains the creation of an OSGi bundle with Maven that integrates JPA and TopLink Essentials as library. This is often needed if an application is distributed on top of an OSGi platform like Eclipse Equinox or Apache Felix.

Maven has a plugin that can be used to create OSGi bundles. The most important part about this plugin is the configuration. The next listing contains the complete configuration followed by explanations to important elements especially in conjunction with TopLink Essentials. The plugin configuration is part of the pom files build section.

Beside TopLink Essentials this also integrates the JGoodies libraries (Forms, Binding and Validation) in the bundle.

      <Bundle-Vendor>Daniel Rohe</Bundle-Vendor>

The first important section is the embed-dependency section. This defines the dependencies that should be embedded into the bundle and loaded into the classpath. In this case all dependencies with the scope compile or runtime that match the groupId com.jgoodies or toplink.essentials and the artifactId forms, bindings, validation or toplink-essentials are imported. This filter exactly matches the three JGoodies libraries and the single TopLink Essentials library.

The next section with the name import-package defines the package imports. In this section I excluded all imports to because they aren’t needed when integrating TopLink Essentials into an application.

The section _exportcontents exports the listed packages which are part of an embedded dependency.


Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden /  Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )


Verbinde mit %s