Apache Sling Feature Model API Regions Extension

Clone this repo:
  1. fc6bb8c [maven-release-plugin] prepare for next development iteration by Carsten Ziegeler · 3 weeks ago master
  2. d72d9d3 [maven-release-plugin] prepare release org.apache.sling.feature.extension.apiregions-1.1.10 by Carsten Ziegeler · 3 weeks ago org.apache.sling.feature.extension.apiregions-1.1.10
  3. b006d70 SLING-9803 : Deprecation info gets lost when durin serialization by Carsten Ziegeler · 3 weeks ago
  4. 859a4d0 SLING-9803 : Deprecation info gets lost when durin serialization by Carsten Ziegeler · 3 weeks ago
  5. b74fa6c Update api-regions.md by Carsten Ziegeler · 3 weeks ago

Apache Sling

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

Apache Sling API Regions Extension for the Feature Model

This component contains extensions relating to the API Regions component. Read the documentation about API Regions for more information.

Feature Model Analysers

This component also contains Feature Model Analysers they are contributed through the Service Loader mechanism to the set of Analysers.

Documentation can be found here: https://github.com/apache/sling-org-apache-sling-feature-analyser . These can be run as part of the ‘analyse-features’ goal with the slingfeature-maven-plugin.

These analysers relate to API Region definitions in Feature Models.

  • api-regions: This analyser ensures that packages listed as exports in API-Regions sections are actually exported by a bundle that's part of the feature.

  • api-regions-dependencies: This analyser checks that packages in API regions listed earlier in the API-Regions declaration have no dependency on API regions listed later in the list. This include Import-Package style dependencies and also uses-clause type dependencies. Later API regions also include packages from earlier declared API regions, but not the other way around.

    • Configuration parameters:
    • exporting-apis: the name of the region that provides the visible APIs.
    • hiding-apis: the name of the region that is ‘hidden’ i.e. not as visible as the exporting one. The packages in the exporting-api cannot depend on any packages from this region.
  • api-regions-duplicates: This analyser ensures that packages are only listed in one region in a given feature. If the same package is listed in multiple regions this will be an error.

  • api-regions-exportsimports: Checks bundle import/export package statements for consistency and completeness. If API Regions are used this analyser includes this information as part of the check, to ensure that bundles don't import packages of which they have no visibility because of API Regions restrictions.

  • api-regions-check-order: This analyser checks that regions are defined in the specified order and that the same region is only declared once. Later regions inherit the packages expose in earlier regions in the list, so the order is important.

    • Configuration parameters:
    • order: A comma separated list of the region names declaring the order in which they should be found. Not all regions declared must be present, but if they are present this order must be obeyed.
  • api-regions-crossfeature-dups: This analyser checks whether there are exported packages in a feature model that does not opt in to the API Regions (i.e. it does not have an API-Regions section) that overlap with exported packages from API regions in other feature models. It can prevent against unwanted results when packages are exported from the outside which should be exported from an API Region. This analyser only provides a useful result when run on an aggregate feature model, i.e. a feature model that was created by aggregating a number of other feature models. It uses the feature-origins metadata to find the features that bundles were initially declared in. It then matches this with the feature-origins found in the api-regions section. Exports from bundles from features that don't declare api-regions are compared to declared exports in the api-regions section. If there is overlap an error is reported.

    • Configuration parameters:
    • regions: a comma separated list of regions to check. If not specified all regions found are checked. This configuration item can be used to exclude certain regions from the check.
    • warningPackages: if packages listed here are found to overlap, a warning instead of an error is reported. Supports either literal package names (e.g. javax.servlet) or wildcards with an asterisk at the end (e.g. javax.*).
    • ignoredPackages: packages listed here are completely ignored in the analysis. Supports literal package names or wildcards with an asterisk at the end.


The following extensions are registered via the ServiceLoader mechanism:


Merge handlers are called when features are merged during the aggregation process.

APIRegionMergeHandler - This handler knows how to merge API Regions extensions

Additional Extensions

The following extensions are also implemented by this component and made available through the Service Loader mechanism:

  • org.apache.sling.feature.launcher.spi.extensions.ExtensionHandler
  • org.apache.sling.feature.launcher.spi.Launcher
  • org.apache.sling.feature.scanner.spi.ExtensionScanner