tags:

views:

398

answers:

3

I'm building my application to run in an OSGi container. I use Maven and the Maven Bundle Plugin from Apache Felix to set up the OSGi manifests for my own modules and that works great.

Now, I'm deploying my bundles into an OSGi container together with several 3rd party libraries. Some of these are already OSGi-fied when I get them from the Maven repos, others, I want to convert into OSGi-compatible jars. I want to set up a Maven project that collects all dependencies, and puts each in its own OSGi jar. The ultimate goal is to collect these jars and my own into an assembly that I can use as a standalone deployment package.

I know how to convert standard jars to OSGi jars, and I have a (somewhat hackish) approach to merge multiple OSGi bundles, even if I probably shouldn't. But if I have a dependency that's already fine as it is, and I just want to copy it from the repo into my assembly, what part of Maven do I use? The bundle plugin is wrong, it messes up the manifests if a dependency is already OSGi-compatible. Do I use the dependency-plugin, the assembly plugin or something else?

I have the feeling I'm overlooking something very simple here.

A: 

You can get OSGi friendly versions of many common artifacts from the Spring bundle repository. So you may not have to do it yourself.

See details of how to configure the bundle repository for Maven.

(will update with some ideas for those that aren't available as bundles already)

Rich Seller
No, I know how to *get* them. I was wondering how to include them in a deployment package and / or test environment automatically using Maven.
Hanno Fietz
sorry, I guess I don't understand exactly what you're trying to do then
Rich Seller
+2  A: 

Did you have a look at the PAX tools? In particular Pax-Runner and pax-construct... They do not only give you a nice template to start with, but also solve most the problems you mentioned for free.

Mirko Jahn
I also recommend the Pax tool suite.
Mattias Holmqvist
Wow, they sure look nice, but I'll have to defer that for now. I just about feel well with Maven, and for the moment, I should be shipping instead of getting more tools. Great hint, anyway!
Hanno Fietz
A: 

We use many libraries which are not OSGified by the vendor and which are not available on the Spring bundle repository. We also have many of these and want to deploy them all together hassle free. For this we have created a 2-layer maven setup:

  1. Individual maven projects that either download or contain (as 'system' scope depends) the 3rd party lib in question, and OSGify these using the Apache Felix bundle plugin
  2. One container project that has a dependency on all of these small projects and makes an assembly of them using the core assembly maven plugin. This POM also uses the copy-dependencies goal of maven to make sure everything is in place.

One it's turned into an assemply (our's is a tar file) we deploy this to our servers. We have gone one step further and used this assembly of 3rd party libraries as the Target Platform for our Eclipse build environment. But this may be irrelevant for you.

omerkudat
Step 2 is what I was asking for, and Step 1 is also quite helpful. Thanks.
Hanno Fietz