0

I have an application which I want to deploy in karaf. I have created a feature file and I am able to add features through this file using karaf console. What I want to achieve now is that create this feature file through maven commands instead of creating it manually and then create a custom karaf distribution using this feature file. How can I achieve it ?

My approach so far is to create a maven module for generating feature file using karaf-maven-plugin and then create another module to generate karaf custom distribution so that we dont need to access maven in production environment.

Is this approach correct ? Do I really need to make two different modules for achieving it. How can I get access to feature file from second module.

These are my poms -

all dependecies

<build>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.karaf.tooling</groupId>
            <artifactId>karaf-maven-plugin</artifactId>
            <version>4.0.5</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <id>generate</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>features-generate-descriptor</goal>
                    </goals>
                    <configuration>
                        <startLevel>80</startLevel>
                        <aggregateFeatures>true</aggregateFeatures>
                        <includeTransitiveDependency>true</includeTransitiveDependency>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

I am not able to figure out the second part yet. Any help with that is really appreciated.

1 Answers1

0

To generate a custom Karaf you just need to use the karaf-maven-plugin.

For example the following will generate a fully working custom Karaf:

        <plugin>
            <groupId>org.apache.karaf.tooling</groupId>
            <artifactId>karaf-maven-plugin</artifactId>
            <version>4.0.0</version>
            <extensions>true</extensions>
            <configuration>
                <!-- no startupFeatures -->
                <bootFeatures>
                  <feature>minimal</feature>
                </bootFeatures>
                <installedFeatures>
                    <feature>wrapper</feature>
                    <feature>spring/4.0.7.RELEASE_1</feature>
                </installedFeatures>
            </configuration>
        </plugin>

This will generate a custom karaf based on the minimal sets of features which are needed to create the minimal distro. If you want to depend on the standard distro just exchange that with standard. Btw. all this is also documented in the Karaf documentation

Achim Nierbeck
  • 5,265
  • 2
  • 14
  • 22
  • Hi, I actually tried this way but i was getting following error - Failed to execute goal org.apache.karaf.tooling:karaf-maven-plugin:4.0.5:assembly (default-assembly) on project deployment-karaf: Unable to build assembly: /Users/Aviral.Shukla/Rep/gee-poc/deployment/target/assembly/etc/config.properties (No such file or directory) .. any idea why I get this error – Aviral Shukla Jul 26 '16 at 07:49
  • what did you try, it's not documented in the above question. please provide more details ... – Achim Nierbeck Jul 27 '16 at 12:55