Awesome
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
apis-jar
This analyser task validates the metadata in the feature model for the apis-jar
goal of the slingfeature-maven-plugin.
bundle-connect
Checks whether the feature is ready for OSGi connect. Bundle with embedded jars are not allowed and packages between bundles must not overlap.
bundle-content
Gives a warning if a bundle contains initial content specified with Sling-Initial-Content
.
bundle-nativecode
Checks for native code instructions in bundles and errors if found.
bundle-packages
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
.
bundle-resources
Gives a warning if a bundle contains resources specified with Sling-Bundle-Resources
.
bundle-unversioned-packages
Checks bundle import/export package statements for missing version information.
check-unused-bundles
Checks for unused bundles, bundles with exports which are not imported.
compare-features
Compares the artifacts in the bundles sections or in an extension between two feature models.
This analyser requires additional configuration:
Configuration key | Allowed values | Description |
---|---|---|
compare-type | ARTIFACTS | The types of entities being compared. Currently only artifacts can be compared. |
compare-with | Maven ID, e.g. mygroup:myart:1.2.3 | The golden feature to compare the features selected for the analyser with. |
compare-extension | extension name | If 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-mode | SAME or DIFFERENT | Whether the sections must be the same or must be different. Defaults to SAME . |
compare-metadata | true or false | Whether to include the artifact metadata in the comparison. Defaults to false . |
content-packages-dependencies
Checks the dependencies between content packages.
content-packages-installables
Checks that content packages do not contain installables for the OSGi installer like bundles or configurations.
content-packages-paths
This analyser checks for allowed and denied paths inside content packages. This analyser requires additional configuration:
Configuration key | Allowed values | Description |
---|---|---|
includes | Content paths | A comma separated list of content paths. If this is specified all content in the content package must match at least one of these. |
excludes | Content paths | A 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. |
content-packages-validation
Runs the default filevault validators on the content packages.
Configuration key | Allowed values | Description |
---|---|---|
enabled-validators | validator ids | A comma separated list of validator-ids to enable |
max-report-level | severity level | Maximum 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. |
duplicate-symbolic-names
Checks if there are duplicates of symbolic names for bundles.
feature-id
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 key | Allowed values | Description |
---|---|---|
accepted-feature-ids | comma-separated list of Maven IDs | The 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). |
repoinit
Checks the syntax of all repoinit sections.
requirements-capabilities
Checks bundle requirements/capabilities for consistency and completeness.
Extensions
analyser-metadata
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 key | Allowed values | Description |
---|---|---|
manifest | null or Object | If null, the manifest is not generated. If an object, the values are copied over. If absent, the values are extracted from the OSGi bundle |
report | Object with keys warning and error | If 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.
Example
A typical configuration for platform applications is:
{
"analyser-metadata:JSON|true":
{
".*" : {
"manifest": null,
"report": {
"error": false,
"warning": false
}
},
"extra-metadata:system.bundle:0": {}
},
"framework":{
"id":"org.apache.felix:org.apache.felix.framework:7.0.5"
},
"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