Apache Karaf custom distribution : patch your configuration from your pom
Apache Karaf Maven plugin enables to build a custom distribution configuring it in your pom.xml. However, part of the configuration was still externalized in configuration file. It was typically the case of the "patches" to apply to the configuration (a.k.a. prop-edits).
File was required in src/main/karaf/assembly-property-edits.xml and was looking like:
<?xml version="1.0"?>
<property-edits xmlns="http://karaf.apache.org/tools/property-edits/1.0.0">
<edits>
<edit>
<file>config.properties</file>
<operation>put</operation>
<key>karaf.framework</key>
<value>felix</value>
</edit>
<edit>
<file>system.properties</file>
<operation>put</operation>
<key>app.key</key>
<value>1234</value>
</edit>
</edits>
</property-edits>
Nothing crazy but it breaks a bit the maintenance of the plugin (if you drop the plugin you likely forget this file, if you change another setting - like a bundle - you don't adjust the config coming from this file, you can configure config (ie config.properties) in the plugin configuration but you can also patch it with this file etc...).
To make it more consistent and selfcontained, this file can now be in the plugin configuration directly. The only small warning is that the operation value is contained in an operation tag since it also take the prepend=[true|false] configuration as sibling tag.
So now (Karaf > 4.3.0.RC1), you assembly configuration can look like:
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf-maven-plugin.version}</version>
<executions>
<execution>
<id>assembly</id>
<phase>prepare-package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
<configuration>
<propertyEdits>
<edits>
<edit>
<file>config.properties</file>
<operation>
<operation>put</operation>
</operation>
<key>karaf.framework</key>
<value>felix</value>
</edit>
<edit>
<file>system.properties</file>
<operation>
<operation>put</operation>
</operation>
<key>app.key</key>
<value>1234</value>
</edit>
</edits>
</propertyEdits>
<!-- ... -->
</configuration>
</plugin>
Indeed, it makes the pom more verbose, but you can browse more easily the whole configuration so at the end it is a real better choice to use that inline configuration.
From the same author:
In the same category: