4

I would like to be more efficient developing OSGi bundles using karaf.

my ideal process will be:

  1. karaf running in the background
  2. deploy all my bundles and dependencies (script)
  3. make karaf watch my maven local repo for any changes in my bundles
  4. package & install individual artifacts and let karaf reload them

At the moment I use karaf assembly for production, but this does not allow me to watch the local maven repo, so each build cycle requires stopping and assembling the full karaf distro and run it again which is slow and inefficient.

I also have a feature describing all the dependencies, it will be great if I can reuse it instead of declaring all dependencies manually.

any suggestions how to accomplish this with karaf?

p.s. can this process be done using Gradle?

Gadi
  • 1,539
  • 22
  • 37

1 Answers1

2

The simplest way is to start karaf clean and install your feature. Of course you can script this part.

Then you type bundle:watch *. This watches your local maven repo for changes in SNAPSHOT bundles.

If you now do mvn clean install on an individual bundle project the bundle is automatically updated.

You can also start karaf with karaf debug. This starts karaf with remote debugging enabled. So you can simply do a debug session with eclipse to the port 5005. This also works nicely with bundle:watch above. While debugging you can change you code and run mvn clean install on the bundle project and continue debugging with the changed bundle. Of course you loose the state of the changed bundle but the rest of the system is unchanged.

Be aware though that bundle:watch only works if your bundles are not deployed to the system folder in karaf. So if you start a custom karaf distro then your bundles will not be updated. This can be worked around by simply deleting these files from system dir as they will then be fetched from the local maven repo. This is very handy when you work on karaf's own code.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64