Search code examples
mavenosgiapache-karafapache-karaf-feature

Package and deploy OSGi bundles and Karaf features in Karaf Container


Recently, I have been working on Apache Karaf project.

The first one is a CXF REST service example and the second one is an Apache Karaf Maven example to run and deploy a Karaf container.

What I would like to do is to combine these two. The idea is to download a couple of JAR files from a repository and then package them into a Karaf.

Building Karaf Assembly manually then deploying the created JAR files in my deploy folder under Karaf is not a good idea if the task is reccurent each day. I would very much like to automate this if possible?


Solution

  • To achieve automatic deploy of Java project in Karaf, follow these steps:

    1. Create a feature project: It is a Maven project and its goal is to create a descriptor of JAR (bundles) to be deployed under Karaf. The packaging of this Maven project is feature.

    2. For your project of Karaf Assembly, add your feature as dependency and add it as boot feature so it can be installed when Karaf is up.

    Look at this project https://github.com/benson-basis/karaf-feature-version-tc. It has all the necessary configuration to automate Karaf building and deploy.