Search code examples
mavenosgikaraf

What is the recommended usage pattern for karaf-maven-plugin?


I have a bunch of java classes and a bundle activator class that I need to deploy to karaf.

I see that the karat-maven-plugin has kar packaging and karaf-assembly.

Also it generates features.xml

I can generate features.xml directly and it generates lines with wrap: for some of my dependent non-osgi jars.

But when I run karat-assembly, I run into the issue of the assembly goal not realizing that these jars are not osgi and end up with errors.

What it the recommended way to get a custom karaf with my application installed ?

Does the karat-assembly packaging need to have a features.xml generated and provided beforehand ? Or is it supposed to do the feature set generation by itself ? If it is the latter, then how do I get around the problem of the karat-assembly not recognizing non-osgi jars ?

I have spent a LOT of time with google and am stumped.


Solution

  • This is my procedure for creating a custom karaf distribution. It may not be "best practice" but it works for me. Maybe you can customize for your needs.

    1. After developing my Camel routes and testing I generate my feature file based on a feature template found in /src/main/feature/feature.xml. The karaf-maven-plugin will generate the feature will in the feature folder inside /target.
    2. I do a clean deploy to our maven artifactory.
    3. I have a custom Karaf project do a clean install on that project. The project has dependencies to the initial project and I add all the features as boot level feature.
    4. Once build I unzip the distribution and run the Karaf app. If everything looks ok its ready to be shipped.