Working with Maven, OSGi and Bndtools
Asked Answered
A

3

10

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?

Among answered 12/5, 2012 at 20:50 Comment(2)
Hi Christian. Thanks for your question and for using Bndtools. I know that the Maven support is still a little lacking but we are actively working on this at the moment. There has been some debate about the best way to do it. Of course we want to avoid declaring dependencies twice, so the POM will be the "master" for build deps. Anyway stay tuned on the mailing list as we will have some announcements in early June. Please also keep giving your feedback and suggestions. Thanks!Poul
Hi Neil. Thanks for answering my question. I was waiting to hear something from you ;) Bndtools is soooo great and in my opinion we do not need Maven in combination with Bndtools. The tool builds all your jars and creates the MANIFEST.MF, same what Maven is doing, but I do not need to specify something in an extra pom file. You are absolutly right to say if we use both, we will declare dependencies twice. Cannot wait for your next release on Bndtools!!! Thanks!Among
A
8

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.

Ashjian answered 13/5, 2012 at 9:36 Comment(0)
P
4

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.

Pteridology answered 12/5, 2012 at 20:55 Comment(5)
Thx @Pteridology for your answer. Did not know that, with Maven there is a possiblity to generate OBR metadata. But since we use Bndtools, all these things are done as well. The creation process of bundles with all information as well as the creation of OBR metadata.Among
I've never use Bndtools, so I don't really know what it's capable of. I do, however, know that Maven has served us very well in the past and has plenty of industry backing.Pteridology
Which version of maven are you using?Varini
3, but worked with 2 for a while too, and it worked just fine.Pteridology
@Oleksi: How hard is it to specify the whole OSGi stuff for the MANIFEST.MF in your pom file since it is plain XML? Because with Bndtools you can write POJO classes with special annotation and your MANIFEST.MF is automatically generated during the building process which just takes the annotations. BUT I found an interesting artical from Neil Bartlett link enabling Maven support on Bntools as well. Would be great if Neil will read the Question here and could tell us his opinion :)Among
S
1

For those coming to this question now, a lot of time has passed since it was originally asked. The Maven work that Neil Bartlett referred to above has matured and there is quite good integration between Bnd/Bndtools and Maven now, including an m2e connector for Eclipse/Bndtools.

Neil co-authored a slideshow on this with Tim Ward:

https://www.slideshare.net/mfrancis/bndtools-and-maven-a-brave-new-world-n-bartlett-t-ward

Sophisticate answered 19/2, 2019 at 2:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.