Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Working with Maven, OSGi and Bndtools

Today I was asked whether it is a good idea to use Maven in our current OSGi application. We used Bndtools and its great since it makes development as easy as possible. Bndtools uses OBR to maintain other bundles and dependency resolution even during the application is running.

Since Maven is widely spreading around and is so popular, mostly all try to use it in OSGi environments too. For me these are two different approaches. OSGi has a its own declaration of dependencies, the MANIFEST.MF and Maven a pom, where you can declare them. So if you use both of them, you will declare dependencies two times. Of course you can use the Apache OSGi Maven Plugin to avoid it and Maven is responsible for creating the MANIFEST.MF. BUT Maven Repositories do not really care about bundles. So it CAN happen that you are referencing to a non bundle jar.

Of course, there are advantages using Maven, but is it really a good thing to combine it with OSGi or specially with Bndtools?

Could somebody provide advantages or disadvantages! Has someone practical experience with using both?

like image 881
christian.vogel Avatar asked May 12 '12 20:05

christian.vogel


2 Answers

I think if pretty much anything you do centers around Maven, then Apache Felix Maven plugin (also based on BND, by the way) is the way to go.

Otherwise if you want to use Maven but in a less central role, Eclipse Tycho makes a lot of sense. Tycho is a set of Maven plugins.

Using Tycho you supply the target platform from Eclipse to Maven, and then it can resolve all bundles by looking at your MANIFEST and target platform. The pom.xml files are really simple for Tycho projects, as they do not contain your dependencies.

Tycho is obviously very Eclipse centric. If you don't use eclipse I don't think it makes much sense, but sometimes it is easier to incorporate in an existing project.

Either way, you can still use the Apache Felix Maven plugin to generate OBR metadata in the deploy phase.

like image 160
Frank Lee Avatar answered Sep 29 '22 07:09

Frank Lee


I think using Maven with OSGi projects works very well. You can use the Felix Maven BND plugin to make your life a lot easier. With this, maven can automatically generate OBR metadata in your local (or remote) maven repository. This lets you treat your maven repository as an OBR as well. It makes the workflow for OSGi projects the same as other projects, and everything is very seamless and fairly easy to use.

We use it at work, and Maven really makes things easier to use. For example, we use Maven to generate Eclipse project files, run automated builds on a CI server, and create OBR metadata.

like image 22
Oleksi Avatar answered Sep 29 '22 05:09

Oleksi