Migration from Gradle with Bnd to Maven Bnd


Firstly, I am sorry for the confusing title of the question as I am new to BnD and I am also confused now. So, it would be very grateful if you could help me out.

Now, we have many OSGI bundles with maven using its pom file. Each OSGI bundle is separated with its maven pom file. Below is code snippet from one of pom file.

<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/maven-v4_0_0.xsd">
						<!-- generic imports for our osgi bundles, add your own -->
						<!-- set your export packages here -->

As each bundle will be built into a jar file separatedly by running “mvn clean install”, I have to deploy them one by one manually to combine an complete application (a group of many bundles). And this approach can not help to build a single executable jar file.

Now, I just figure out BnD can help me to group all the bundle and build them into a single executable jar file. I am planning to find a way to migrate the existing maven pom file with maven command to work with bnd.

I have tried Bnd Workspace, Gradle build but it brings me some unknown issues from IDE Eclipse that I have no idea how to fix them. So, I am trying to find a way to use maven to build my code like now. I heard there is a plugin called bnd-maven-plugin but the Github README does not provide a clear guideline how to migrate it from a maven pom file. Below is my try but it does not work. It seems that everything under bnd is ignored when packing, no exporting or importing classes in the Jar file…

				<!-- New for BND-->
						Bundle-Activator: abc.ac.ac.Activator
						Import-Package: \
						Export-Package: \

I am quite new to bnd so it would be very grateful if you could give me a guideline how to ultilize my existing maven build with pom file to work with bnd. Thank you so much!


You can find a nice example here: osgi-test/examples/osgi-test-example-mvn at main · osgi/osgi-test · GitHub

I may need to see the full pom to get an idea, why the configuration seems to be ignored. 2 Things jump at me though:

  1. The bnd config as this blob in the pom.xml is always a bit ugly. You can put a bnd.bnd file next to your pom and do the configuration in there. Works much better.
  2. The Config itself:
Bundle-Activator: abc.ac.ac.Activator
Import-Package: \
    # The resolution was quoted wrongly in your example
    # This is the catch all that tells bnd to calculate the rest of the Imports
    # There was a second dot in your statement, not sure what that did

I hope that helps a bit.

1 Like