[maven-release-plugin] copy for tag org.apache.sling.providertype.bnd-plugin-1.0.0
[maven-release-plugin] prepare release org.apache.sling.providertype.bnd-plugin-1.0.0
1 file changed
tree: a662848477cf7b70792012dab43e27310b5b1634
  1. src/
  2. .asf.yaml
  3. .gitignore
  4. CODE_OF_CONDUCT.md
  5. CONTRIBUTING.md
  6. Jenkinsfile
  7. LICENSE
  8. pom.xml
  9. readme.md
readme.md

Apache Sling

Build Status Test Status Coverage Sonarcloud Status JavaDoc Maven Central License

Apache Sling Provider Type Checker Bnd Plugin

This module contains a Bnd plugin enforcing that no class of the current bundle extends or implements a provider type. Note that using a provider type (i.e. calling its methods without implementing or extending it) is still allowed (even for consumers).

That ensures that the import-package version ranges are not narrow but broad and the risk that the bundle is incompatible with newer versions of its dependent bundles is less likely.

Usage

For usage with Maven the Bnd plugin has to be added to the plugin dependencies of bnd-maven-plugin (or maven-bundle-plugin) like this:

<plugin>
    <groupId>biz.aQute.bnd</groupId>
    <artifactId>bnd-maven-plugin</artifactId>
    <extensions>true</extensions>
    <dependencies>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.providertype.bnd-plugin</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
</plugin>

In addition the bnd.bnd file needs to register the Bnd plugin with the plugin instruction

-plugin.providertype:org.apache.sling.providertype.bndplugin.ProviderTypeScanner

Configuration

To explicitly ignore certain provider types (i.e. don't fail when these are extended/implemented) one can use the attribute ignored with one or multiple comma-separated fully qualified provider type names. For example

-plugin.providertype:org.apache.sling.providertype.bndplugin.ProviderTypeScanner;ignored=org.apache.jackrabbit.api.security.user.User

Prerequisites

  • Bnd 6.0 or newer (integrated in bnd-maven-plugin version 6.0.0+ or maven-bundle-plugin version 5.1.5+)
  • Java 11 or newer

Provider Type Information

The information whether a type (i.e. a class or interface) is designed to be extended/implemented only by providers or also by consumers is determined originally from the the annotations @org.osgi.annotation.versioning.ProviderType or @org.osgi.annotation.versioning.ConsumerType. In order to speed up the check the annotation is evaluated and extracted into a dedicated JSON file named META-INF/api-info.json when generating the apis jar and being looked up from there within this plugin.