1 ~~ Licensed to the Apache Software Foundation (ASF) under one
2 ~~ or more contributor license agreements. See the NOTICE file
3 ~~ distributed with this work for additional information
4 ~~ regarding copyright ownership. The ASF licenses this file
5 ~~ to you under the Apache License, Version 2.0 (the
6 ~~ "License"); you may not use this file except in compliance
7 ~~ with the License. You may obtain a copy of the License at
9 ~~ http://www.apache.org/licenses/LICENSE-2.0
11 ~~ Unless required by applicable law or agreed to in writing,
12 ~~ software distributed under the License is distributed on an
13 ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 ~~ KIND, either express or implied. See the License for the
15 ~~ specific language governing permissions and limitations
26 All packagings require that you mention the karaf-maven-plugin in pluginManagement or plugins with the extension element:
30 <groupId>org.apache.karaf.tooling</groupId>
31 <artifactId>karaf-maven-plugin</artifactId>
32 <version>${karaf.version}</version>
33 <extensions>true</extensions>
37 You will also need to mention the karaf-maven-plugin in some build/plugins section of your pom or ancestor pom. The examples below assume extensions is set in
38 a pluginManagement section or an ancestor pom.
42 Specify the feature packaging in your pom with
45 <packaging>feature</packaging>
48 The feature packaging lifecycle uses these mojos:
53 org.apache.karaf.tooling:karaf-maven-plugin:generate-features-xml
56 org.apache.maven.plugins:maven-install-plugin:install
59 org.apache.maven.plugins:maven-deploy-plugin:deploy
64 Here's an example of a feature project with all configuration options set:
68 <groupId>org.apache.karaf.tooling</groupId>
69 <artifactId>karaf-maven-plugin</artifactId>
71 <startLevel>50</startLevel>
72 <aggregateFeatures>true</aggregateFeatures>
73 <resolver>(OBR)</resolver>
75 <checkDependencyChange>true</checkDependencyChange>
76 <warnOnDependencyChange>true</warnOnDependencyChange>
77 <logDependencyChanges>true</logDependencyChanges>
78 <overwriteChangedDependencies>true</overwriteChangedDependencies>
83 This packaging results in a features xml descriptor including a feature with the project artifactId as name and project version as version.
85 The suitably scoped project jar dependencies are added to this feature as bundles. Compile and provided scope result in the dependency attribute false (unset) and
86 runtime scope results in the dependency attribute set true.
88 startLevel determines the startLevel of bundles added to the constructed feature.
90 kar project dependencies are added to the constructed feature as dependencies.
92 If aggregate features is false or not set, feature project dependencies are added to the constructed feature as dependencies. If aggregateFeatures is true,
93 the features of all feature project dependencies are extracted from the dependency feature xml files and added as features to the constructed features xml.
95 If a source src/main/feature/feature.xml file is provided then it is filtered and used as a base for the generated feature xml file. If there is a feature of the appropriate name
96 it is extended with the project dependencies, otherwise one is created. This allows you to specify alternate startLevels, configuration files, and configuration as well as
97 completely configuring the feature xml file by hand.
99 The dependency change options allow you to set up change tracking so you can be alerted if the transitive project dependencies included in the feature have changed. To turn this on set
100 checkDependencyChange true. A stripped down feature xml file will be written to src/main/history/dependencies.xml that includes one feature with all the bundles from all the features.
101 Subsequent builds will compare this historical file with a similar current file. If it has changed, the new dependencies.xml added and removed lists,
102 and a dependency tree will be written to target/history, and various options are available.
103 If warnOnDependencyChange is missing or false, the build will fail.
104 If logDependencyChanges is set, the added and removed lists will be shown in the maven build output.
105 If overwriteChangedDependencies is set the historical src/main/history/dependencies.xml file will be overwritten with the new contents.
107 While the determination of bundle transitive dependencies uses aether, just like maven, the algorithm is slightly different. We traverse the entire dependency graph
108 and exclude bundle dependencies that are included as project dependencies of feature and kar dependencies. Currently dependencies that are supplied in source feature xml
109 of dependent features and kars are not tracked.
113 Specify the kar packaging in your pom with
116 <packaging>kar</packaging>
119 The kar packaging lifecycle uses these mojos:
124 org.apache.maven.plugins:maven-resources-plugin:resources
127 org.apache.karaf.tooling:karaf-maven-plugin:generate-features-xml
130 org.apache.karaf.tooling:karaf-maven-plugin:archive-kar
133 org.apache.maven.plugins:maven-install-plugin:install
136 org.apache.maven.plugins:maven-deploy-plugin:deploy
141 kar packaging configuration is exactly the same as feature packaging configuration. All bundles that are not marked as dependencies in the feature.xml output from the xml generation stage are
142 added to a maven-repo-like structure in the target kar. In addition any resources from src are added. Resources need to be under "resources" in the src resource directory in order to get
143 unpacked when the kar is installed. For example with default maven-resource-plugin configuration src/main/resources/resources/etc/foo.cfg will result in resources/etc/foo.cfg in the kar and
144 etc/foo.cfg when installed in the server.
149 Specify the karaf-assembly packaging in your pom with
152 <packaging>karaf-assembly</packaging>
155 The karaf-assembly lifecycle uses these mojos:
160 org.apache.maven.plugins:maven-resources-plugin:resources,
161 org.apache.karaf.tooling:karaf-maven-plugin:assembly
166 org.apache.karaf.tooling:karaf-maven-plugin:archive-server
169 org.apache.maven.plugins:maven-install-plugin:install
172 org.apache.maven.plugins:maven-deploy-plugin:deploy
177 Here's an example of a karaf-assembly project with all configuration options set:
181 <groupId>org.apache.karaf.tooling</groupId>
182 <artifactId>karaf-maven-plugin</artifactId>
184 <defaultStartLevel>50</defaultStartLevel>
189 property-file-edits specifies the location of an XML file that specifies edits to 'etc' files as they are
190 copied from the reference to the assembly. By default, the value of this parameter is src/main/karaf/assembly-property-edits.xml;
191 if you add a file at that location, the plugin will apply the edits you specify in it.
193 defaultStartLevel determines the start level of bundles that do not have startLevel set in the feature xml descriptor. If not set, the default is 30.
195 Project dependencies that are feature or kar packaging are treated differently depending on whether they are scope runtime, or compile/provided. Runtime scope dependencies are installed
200 - unpacks the resources content from project dependencies that are kars
202 - unpacks the system maven-repo-like structure from project dependencies that are kars. If the project dependency is scope compile or provided it is unpacked to system.
204 - locates and installs all the bundles mentioned in feature xml descriptors that are project dependencies or located in project dependencies that are kars of scope compile/provided.
206 - constructs a startup.properties file that includes all the bundles mentioned in feature descriptors of scope compile/provided at the specified or default start level.
208 - adds the feature project dependencies and features in kar dependencies of scope runtime to the features service configuration.
210 The result is packed up into zip and tar.gz assemblies. Normally to get a working server you would include at least the karaf-framework kar and most likely the karaf-full kar: these are used
211 to assemble the minimal and full server.