Sunday, 3 August 2008

Bushel: Making OSGi bundle management easier with Ivy

I've decided to start building an application in my so called spare time, to see if I can make a business out of it in the long term. I'll reveal more about the application, if and when I have something interesting to show. The app is currently being developed using the Eclipse RCP and OSGi, mainly because I was keen to learn how to use these technologies to build an application. So far it's been a bit of a struggle to figure out the best way to layout a project, manage bundle granularity and a few other best practice things. The first problem I came across was, how to manage my dependencies. As much as I like using the Eclipse PDE, I still prefer to have an Ant script to build my application. In particular when I get a build server up and get some continuous integration good-ness happening. So, how do I collect only the bundles I am using in my application, in one place, with minimal fuss, and easily add new bundle dependencies, without manually copying files? Well, this has been solved with plain jars, just look at Maven or Ivy. But bundles are still relatively new and the best practice is still evolving... we'll as far as I can tell anyways. I chose to use Ivy, because it's a little less opaque than Maven. I won't say it's better. It's just more my flavour. So, I've slapped together an Ant Task to help build a local Ivy repo from ad-hoc bundles. I've made it freely available from here. And you can get a more detailed example of what I am doing in the following tutorial. I'd be keen on feedback, especially if anyone know of a better way to do what I'm doing. I've google'd as much as I care to on the topic and didn't find any solutions. So any tips would be much appreciated. A.

4 comments:

Jérôme BENOIS said...

Hi Alex,

I like the idea of managing bundles dependencies with Apache Ivy. I tested Bushel, it's simple and great!
I already thinking about how to deal with Ivy and OSGI. Indeed, i think also that use Ivy is more powerful and simple than eclipse PDE to integrate in build server and continous integration process.
However, I think the better way is define a new module descriptor parser (http://ant.apache.org/ivy/history/latest-milestone/configuration/parsers.html) like the Ivy standard descriptor parser or the Maven POM parser provided by Ivy. And use this parser with an Ivy resolver (http://ant.apache.org/ivy/history/latest-milestone/configuration/resolvers.html) like this :

< filesystem name="osgi-eclipse-3.4-jars-repo" >
< ivy pattern="/workspace/bundles/eclispse-3.4/plugins/*.jar!META-INF/MANIFEST.MF"/ >
< / filesystem >
or
< filesystem name="osgi-eclipse-3.4-dir-repo" >
< ivy pattern="/workspace/bundles/eclispse-3.4/plugins/**/*META-INF/MANIFEST.MF"/ >
< / filesystem >

And you can use theses resolvers to build your own repository (http://ant.apache.org/ivy/history/latest-milestone/tutorial/build-repository.html).

And i think read a "Require-Bundle" OSGi attribute is required to provide transitive dependencies support.

Maybe we can study together a solution based on your Bushel.groovy code. What do you think about it ?

My two cents,
Jérôme.

alexr said...

Hi Jérôme,

Thanks for your feedback.

I like the idea of the descriptor parser, it solves a few problems I was think about. Mainly, reducing duplicate copies of bundles, and how to handle 'exploded' bundle jars elegantly.

If you send me your googlemail name, i will add you as a project member.

A.

Gurney said...

Any progress on OSGi manifest parser for Ivy so far? I am keen to use it and probably can pick up development of the parser, if there is some code for this already.

alexr said...

Hi Gurney,

You can check out the latest source from here: http://code.google.com/p/bushel/source/checkout

Since this blog there has been quite a bit of work done, so I recommend you take a look.

Alex.