Skip to content

3.4. Karaf features

Guilherme Raimundo edited this page Jan 23, 2019 · 5 revisions

Only manually edit a feature if the automatic generation for it is not supported

In order to improve maintainability of our builds we should prevent manual intervention as much as possible. If features are generated automatically, then we can be sure that changes to our code are reflected appropriately in the generated feature.

To include bundles or features in the generated feature, you should define them as dependencies in the POM file of the maven module that is responsible for the feature generation. The build tools will then automatically include in the generated feature any necessary transitive dependencies.

There are some cases where we need to manually define things in the feature descriptor itself. Currently this is the case of bundles that require a custom deployer (e.g. platform-plugin-deployer, pentaho-webjars) and depending features that are not published in their own artifact. If you manually define a dependency in the feature file, make sure to also include that dependency, with scope provided, in the POM file of the maven module that is responsible for the feature generation. This is needed to maintain traceability of dependencies. Take notice that since you are manually adding things to the feature descriptor, you’ll also need to manually provide any required transitive dependencies.

Have one feature per feature repository

Following the “automatic feature generation” guideline, when generating a feature FG that depends on a feature FD, we should add the feature repository FR, that contains feature FD, as a maven dependency of the maven module that is responsible for generating FG. However, if FR also contains other features, then the automatic generation of FG will also include those other features. Because, in the maven dependency declaration, there is no way to specify what particular feature from the feature repository of the referenced artifact we want to include, we choose to generate our feature repositories with a single feature. This allows us to maintain our feature generation automatic when depending on other features.

If you need to depend on a third-party feature repository that contains multiple features, then you should:

  • Add the feature repository, that contains the dependent feature as a dependency, with scope provided, in the POM file of the maven module that is responsible for the feature generation
  • Manually reference the feature repository in the partially generated feature with the tag
  • Manually reference the dependent feature in the partially generated feature

Do not add a feature to the current existing manually defined feature repositories

Features should be generated in assembly maven modules of the respective project. The existing manually defined feature repositories can be found here.