views:

388

answers:

2

I'm looking for a developmentn model with fast turnaround times when developing a multi-module, maven built, OSGi application.

Actually, the best solution seems to be Pax Construct's maven plugin (which in turn calls Pax Runner) for provisioning maven generated bundles. However, I didn't find a way howto deploy to a running OSGi container with help of this (or another) maven plugin. mvn pax:run always starts the OSGi platform afresh. AFAIK it is also not possible to deploy to an already exisiting OSGi container not managed by Pax Runner (e.g. Glassfish v3 or SpringSource dm Server).

Does there exist a maven plugin which allows for quickly deploying a maven module to a running OSGi container, ideally being able to hook into the packaging lifecycle phase ?

How is your development cycle when developing OSGi based applications with maven ?

+1  A: 

I don't know any generic plugin doing that but, with GlassFish, deploying an OSGI bundle invovles using the --type osgi parameter when calling deploy:

asadmin deploy --type osgi my-osgi-bundle-x.y.z.jar

Sadly, I couldn't find any support for the type option in the maven-glassfish-plugin. However, the maven-embedded-glassfish-plugin does have a embedded-glassfish:admin goal allowing to:

executes the specified admin command on the embedded server. For example, you could create a jdbc resource.

The plugin is not well documented, its setup will require some investigation and I didn't test this but, if you can pass --type osgi to the embedded-glassfish:admin goal (which is my understanding), then it should be possible to bind the goal on a particular phase and to perform an OSGI bundle deployment as part of your standard build.

Pascal Thivent
+2  A: 

If you are using glassfish, you can configure maven's target/ directory to be watched by GlassFish for updates and then GlassFish will automatically install & start the jar when it gets created, it will uninstall it when the jar gets deleted and update the bundle, when the jar gets updated in target directory. To achieve this, create a file called

org.apache.felix.fileinstall-maven.cfg with content like this: felix.fileinstall.dir=/path/to/target/ felix.fileinstall.poll=5000 felix.fileinstall.bundles.new.start=true

Place this file in domain1/autodeploy/bundles/

For further questions, mail glassfish users alias. Sahoo

Sahoo