Search code examples
javamavenosgiapache-felixbnd

Feedback on Maven multi-module project setup with OSGi


I am getting in touch with OSGi and trying to setup a project using Apache Felix and Maven. I'd like to use a Multi-Module build and declarative services. The project is hosted on GitHub: osgi-maven-example (Note that the link points to a specific commit and not to the HEAD of the repository.)

I have got a few questions about the overall setup of the project:

  • According to Neil Bartlett the bnd-maven-plugin should preferably used over the Apache Felix Bnd Plugin because it respects Maven's lifecycle. Judging by the age of the bnd-maven-plugin, this seems to be a relatively new approach and I am therefore not sure if it is a good idea to do so.

  • I am using the declarative services package (org.apache.felix.scr.annotations) from Apache Felix to define my components. These annotations are used by the maven-scr-plugin to generate service descriptors which are included in the MANIFEST.MF by the use of the following line in the bnd.bnd file: Service-Component: OSGI-INF/*.xml. Is this the way declarative services are intended to be used?

  • IntelliJ displays a warning in the GermanGreeter-class: intellij-warning
    What exactly does this mean? Do I need to care about this? How can I fix it?

Although I am pretty happy over this working example, I am curious if I am using all these technologies in their intended way and I would be very grateful if I could get some feedback on the overall setup before I am starting to use it in a bigger project.


Solution

  • There is now an official set of annotations for DS, under the package org.osgi.service.component.annotations. These annotations are packaged in the jar "compendium" (org.osgi/cmpn), and bnd has a directive to generate components descriptors : -dsannotations : *

    the first part of your question is subject to opinions... maven-bundle-plugin is more "maven centric" : it's more easy to integrate it in a maven build. bnd-maven-plugin is more "bnd centric" : you manipulate standard bnd files, but it broke some maven convention. both have advantage and inconvenient