Using the karaf-maven-plugin

The Karaf Maven plugin allows you:

* to work with Karaf features: validate a features descriptor, add features bundle into a repository, create a KAR archive from a features descriptor, etc.
* to create Karaf commands help: it generates help from Karaf commands
* to modify Karaf instances and create distributions

Packagings

The most generally useful features of the karaf-maven-plugin are exposed as packagings. To use the packagings the pom or an ancestor must configure the karaf-maven-plugin with extensions:

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.karaf.tooling</groupId>
                    <artifactId>karaf-maven-plugin</artifactId>
                    <version>3.0.3-SNAPSHOT</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

Then specify the packaging in your project as usual, e.g.

    <packaging>kar</packaging>
Packaging Description
feature The feature packaging generates a features.xml descriptor using the karaf:features-generate-descriptor
kar The kar packaging generates a features.xml descriptor using the karaf:features-generate-descriptor and then packages a kar using the karaf:features-create-kar
karaf-assembly Assembles a Karaf server based on the features descriptors and kar files listed as Maven dependencies.

Commands goals

The karaf-maven-plugin is able to generate documentation for Karaf commands:

Goal Description
karaf:commands-generate-help Generates help for Karaf commands.

Features goals

Normally you should use the features or kar packagings instead of these individual goals.
The karaf-maven-plugin provides several goals to help you create and validate features XML descriptors as well as leverage your features to create a custom Karaf distribution.

Goal Description
karaf:features-generate-descriptor Generates a features XML descriptor for a set of bundles. Used in feature and kar packagings.
karaf:features-validate-descriptor Validate a features XML descriptor by checking if all the required imports can be matched to exports
karaf:features-create-kar Assemble a KAR archive from a features XML descriptor. Used in kar packaging.

Instances and distributions goals

Normally you should use the karaf-assembly packaging instead of this individual goal.
The karaf-maven-plugin helps you to build custom Karaf distributions or archives existing Karaf instances:

Goal Description
karaf:install-kars Assemble a server from Maven feature-repo and kar dependencies. Used in karaf-assembly packaging. See karaf-assembly.
karaf:instance-create-archive Package a server archive from an assembled server. . Used in karaf-assembly packaging. See also karaf-assembly.
karaf:features-add-to-repository (old style manual assemblies) Copies all the bundles required for a given set of features into a directory
(e.g. for creating your own Karaf-based distribution)