I am relatively new to the OSGi world and need help to understand how to automate my build process. I got myself familiar with using bndtool in Eclipse and I learnt how to resolve dependencies, run, test, debug and generate a standalone jar. I also went through the basic and Maven tutorial posted in the OSGi official site. My problem is how to automate my builds! So, let's say I have the code in SVN. I need to be able to check out the code then run a build script/tool to generate my bundles which then I can deploy with Felix or Karaf. The official Maven-based tutorial (with OSGi enRoute) shows only how to generate a standalone jar which is not what I am interested in; I need to generate bundles. I read about the Maven Bundle Plugin, but I think when using it I will lose all the luxury the UI-based bndtools offer with Eclipse. Many thanks for helping!
4 Answers
If you use the maven build with bndtools then you indeed loose some of the benefits. I have an example for a full project using the maven build. See osgi-chat. It uses the bnd-maven-plugin to build the bundles but you can also use the maven-bundle-plugin. In both cases you use the standard m2e support in eclipse. Bndtools is then only involved in resolving the bundles and creating the runnable jar.
We use a pure maven approach at many projects in the apache community. It is the proven way to deploy on apache karaf. If you want to deploy to karaf then bndtools will not help a lot as it can not create karaf features.
If you want all the IDE support of bndtools then use a native bndtools build with a bndtools workspace (cnf dir) and use the gradle build it provides.

- 19,420
- 2
- 39
- 64
Bndtools comes with a gradle plugin, you can use that to export an executable jar but if you just run the build the jars will be available in the generated folder of each project.
You can use the runbundles task to export bundles based on a .bndrun file (this works similar to generating the executable jar but just creates a folder containing the bundles)

- 111
- 1
Being a longtime maven user and also because I am planning to use karaf (jboss fuse) I followed Christian's suggestions and spent some time exploring the maven-bundle-plugin and planning to explore the bnd-maven-plugin. From first readings about bnd-maven-plugin, I found that it has some advantages over the apache plugin (gets instructions directly from the bnd rather than the pom; faster updates expected parallelly to the bnd updates). One thing I still need to understand about this plugin: which OSGi release version does it generate bundles for? I know that the maven-bundle-plugin generates for R4 only, according to the official site, which is a limitation. What about bnd-maven-plugin? One more question: which plugins are available for generating karaf kars and can they be combined with the bnd-bundle-plugin? Many thanks for your patience!

- 139
- 1
- 10
I've spent some time exploring the bnd-maven-plugin. This is the best way I could find for mixing Eclipse, the bnd-maven-plugin and bndtools: 1. use the bndtools to resolve the requirements and run the bundles inside a framework from within Eclipse. 2. use the bnd-maven-plugin for building the bundles 3. use the 'indexer' plugin for generating an index file to be used for the dependency resolutions by bndtools. Even though this method allows to run the bundles from within Eclipse, a 'mvn install' is required each time because the bndtools plugin does not know how to resolve dependencies from the Eclipse workspace. This method also makes it impossible to debug the code in Eclipse. Is there any better alternative?
Thanks

- 139
- 1
- 10