As Karaf is an OSGi container, it's heavily used as the kernel of applications and middlewares.
You could require to construct your own Karaf distribution matching your requirements.
This custom distribution could contain:
Basically a Karaf custom distribution is:
1. Uncompressing a standard Karaf distribution in a given directory.
2. Populating the system repo with your features.
3. Populating the lib directory with your branding or other system bundle jar files.
4. Overriding the configuration files in the etc folder.
These tasks could be performed using scripting, or more easily and portable, using Apache Maven and a set of Maven plugins.
For instance, the Maven POM could look like:
The Maven POM will download the Karaf standard distribution and prepares resources to be processed by the Maven assembly plugin.
Your Maven project structure should look like:
For instance, src/main/filtered-resources could contains:
my-features.xml where maven properties will be replacedetc/org.apache.karaf.features.cfg file containing your my-features descriptor:
The src/main/distribution contain all your custom Karaf configuration files and script, as, for examples:
Now, we can "assemble" our custom distribution using the Maven assembly plugin. The Maven assembly plugin uses an assembly descriptor in the src/main/descriptors/bin.xml:
To build you custom Karaf distribution, just do:
You will find your Karaf custom distribution tar.gz in the target directory.
A distribution goal is in preparation in the next Karaf