...
Code Block |
---|
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM http://maven.apache.org/xsd/maven-4.0.0.xsd"> <groupId>my.company</groupId> <artifactId>mycustom-karaf</artifactId> <version>1.0</version> <packaging>pom</packaging> <name>My Unix Custom Karaf Distribution</name> <properties> <karaf.version>2.1.3</karaf.version> </properties> <dependencies> <dependency> <groupId>org.apache.karaf</groupId> <artifactId>apache-karaf</artifactId> <version>${karaf.version}</version> <type>tar.gz</type> </dependency> <dependency> <groupId>org.apache.karaf</groupId> <artifactId>apache-karaf</artifactId> <version>${karaf.version}</version> <type>xml</type> <classifier>features</classifier> </dependency> </dependencies> <build> <resources> <resource> <directory>${project.basedir}/src/main/filtered-resources</directory> <filtering>true</filtering> <includes> <include>**/*</include> </includes> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <executions> <execution> <id>filter</id> <phase>generate-resources</phase> <goals> <goal>resources</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.karaf.tooling</groupId> <artifactId>features-maven-plugin</artifactId> <version>${karaf.version}</version> <executions> <execution> <id>add-features-to-repo</id> <phase>generate-resources</phase> <goals> <goal>add-features-to-repo</goal> </goals> <configuration> <descriptors> <descriptor>mvn:org.apache.karaf/apache-karaf/${karaf.version}/xml/features</descriptor> <descriptor>file:${project.basedir}/target/classes/my-features.xml</descriptor> </descriptors> <features> <feature>my-feature</feature> </features> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy</id> <phase>generate-resources</phase> <goals> <goal>copy</goal> </goals> <configuration> <!-- TODO complete with dependency plugin section --> </ Define here the artifacts which should be considered in the assembly --> <!-- For instance, the branding jar --> <artifactItems> <artifactItem> <groupId>my.groupId</groupId> <artifactId>my.branding.id</artifactId> <version>1.0</version> <outputDirectory>target/dependencies</outputDirectory> <destFileName>mybranding.jar</destFileName> </artifactItem> </artifactItems> </configuration> </execution> <execution> <!-- Uncompress the standard Karaf distribution --> <id>unpack</id> <phase>generate-resources</phase> <goals> <goal>unpack</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>org.apache.karaf</groupId> <artifactId>apache-karaf</artifactId> <type>tar.gz</type> <outputDirectory>target/dependencies</outputDirectory> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <id>bin</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptors> <descriptor>src/main/descriptors/bin.xml</descriptor> </descriptors> <appendAssemblyId>false</appendAssemblyId> <tarLongFileMode>gnu</tarLongFileMode> </configuration> </execution> </executions> </plugin> </plugins> </build> </project> |
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:
- pom.xml: the previous POM file
- src/main/descriptors/bin.xml: the assembly maven plugin descriptor (see below)
- src/main/filtered-resources: contains all files where some maven properties should be replaced/filtered. Typically, it contains the features descriptor and configuration files.
- src/main/distribution: contains all raw files which will be copied into your custom distribution.
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:Code Block # # Comma separated list of features repositories to register by default # featuresRepositories=mvn:org.apache.karaf/apache-karaf/${karaf.version}/xml/features,mvn:my.groupId/my-features/${project.version}/xml/features # # Comma separated list of features to install at startup # featuresBoot=config,ssh,management,my-feature
TODO Complete
Roadmap
A distribution goal is in preparation in the next Karaf
Custom distribution examples
...