Apache Sling Feature Model Analyser

Clone this repo:
  1. 62ee62e [maven-release-plugin] prepare for next development iteration by Robert Munteanu · 4 weeks ago master
  2. eacba58 [maven-release-plugin] prepare release org.apache.sling.feature.analyser-2.0.8 by Robert Munteanu · 4 weeks ago org.apache.sling.feature.analyser-2.0.8
  3. 7fae43b SLING-12353 - The AnalyserMetaDataHandler is executed too often (#48) by Robert Munteanu · 4 weeks ago
  4. 74c222f [maven-release-plugin] prepare for next development iteration by Robert Munteanu · 4 weeks ago
  5. 37895f9 [maven-release-plugin] prepare release org.apache.sling.feature.analyser-2.0.6 by Robert Munteanu · 4 weeks ago

Apache Sling

Build Status Test Status Coverage Sonarcloud Status JavaDoc Maven Central feature License

Feature Model Analyser

The Analyser can analyse features for completeness and correctness. The analyser is pluggable and can perform custom checks.

Running the Analyser as a Maven Plugin

The Analyser can also be run as part of a Maven build via the slingfeature-maven-plugin

Analyser Tasks

Below is a list of built-in analysers. Additional analysers in relation to Feature Model API Regions can be found in org-apache-sling-feature-extension-apiregions, analysers performing checks on class level can be found in org-apache-sling-feature-analyser-classes.

For further documentation see: Feature Model


This analyser task validates the metadata in the feature model for the apis-jar goal of the slingfeature-maven-plugin.


Checks whether the feature is ready for OSGi connect. Bundle with embedded jars are not allowed and packages between bundles must not overlap.


Gives a warning if a bundle contains initial content specified with Sling-Initial-Content.


Checks for native code instructions in bundles and errors if found.


Checks bundle import/export package statements for completeness. Does not take API Regions into account. An expanded variant of this analyser is available in org-apache-sling-feature-extension-apiregions under the name api-regions-exportsimports.


Gives a warning if a bundle contains resources specified with Sling-Bundle-Resources.


Checks bundle import/export package statements for missing version information.


Checks for unused bundles, bundles with exports which are not imported.


Compares the artifacts in the bundles sections or in an extension between two feature models.

This analyser requires additional configuration:

Configuration keyAllowed valuesDescription
compare-typeARTIFACTSThe types of entities being compared. Currently only artifacts can be compared.
compare-withMaven ID, e.g. mygroup:myart:1.2.3The golden feature to compare the features selected for the analyser with.
compare-extensionextension nameIf this configuration is absent, the feature's bundles are compared. Otherwise the extensions with the specified name are compared. These extensions must be of type ARTIFACTS.
compare-modeSAME or DIFFERENTWhether the sections must be the same or must be different. Defaults to SAME.
compare-metadatatrue or falseWhether to include the artifact metadata in the comparison. Defaults to false.


Checks the dependencies between content packages.


Checks that content packages do not contain installables for the OSGi installer like bundles or configurations.


This analyser checks for allowed and denied paths inside content packages. This analyser requires additional configuration:

Configuration keyAllowed valuesDescription
includesContent pathsA comma separated list of content paths. If this is specified all content in the content package must match at least one of these.
excludesContent pathsA comma separated list of content paths. If this is specified all content in the content package must not match any of these - except it matches an include.


Runs the default filevault validators on the content packages.

Configuration keyAllowed valuesDescription
enabled-validatorsvalidator idsA comma separated list of validator-ids to enable
max-report-levelseverity levelMaximum severity level to report. (INFO, WARN, ERROR) defaults to WARN. Higher level messages will be downgraded to the sepcified level. The default will never break a build.


Checks if there are duplicates of symbolic names for bundles.


This analyser checks that the feature id matches one of the given accepted feature ids. If it doesn't it will emit an error.

This analyser requires additional configuration:

Configuration keyAllowed valuesDescription
accepted-feature-idscomma-separated list of Maven IDsThe Maven ID/coordinates have the format groupId:artifactId[:packaging[:classifier]]:version. Each item is either a string which must be equal to the according item of the feature id, or a * which acts as wildcard (i.e. everything matches).


Checks the syntax of all repoinit sections.


Checks bundle requirements/capabilities for consistency and completeness.



Generates additional metadata that will be recorded in the feature model definition. This additional metadata is used later on to influence the behaviour of the analysers.

This extension is not available by default using the ServiceLoader mechanism and must be explicitly registered.

It is configured by defining an analyser-metadata section in the feature model definition. The section will be processed by the extension when the feature models are aggregated and will be replaced with the required entries for bundles matching the configuration.

Bundle metadata

The section can have entries that match individual bundle names and entries that match based on regular expressions (if the key contains the “*” character).

Each individual entry can contain the following keys:

Configuration keyAllowed valuesDescription
manifestnull or ObjectIf null, the manifest is not generated. If an object, the values are copied over. If absent, the values are extracted from the OSGi bundle
reportObject with keys warning and errorIf any of the values are set to false, reporting is suppressed for those kind of occurences.

Framework metadata

A special case is when an entry with the name extra-metadata:system.bundle:0 is found. This will record information about the system bundle exported packages and capabilites as present at the time of the feature aggregation. When these are present in an aggregated feature the analysers will use that information instead of the one discovered during analysis time.

The system bundle information will be extracted from the execution-environment extension. In this extension, the framework entry is required and is used to gather information about the system bundle. The javaVersion property is optional but recommended and is used to validate that the Java version used to generate the metadata matches the one in the execution environment.


A typical configuration for platform applications is:

      ".*" : {
        "manifest": null,
        "report": {
          "error": false,
          "warning": false
      "extra-metadata:system.bundle:0": {}
      "javaVersion": "21"

This ensures that

  • warnings related to the platform are not reported when the feature is aggregated with downstream (consumer) applications. The manifests should not be inlined under normal circumstances, since it greatly increases the size of the resulting features.
  • metadata related to the system bundle is recorded at the Java 21 compatibility level