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 (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.
For usage with Maven the Bnd plugin has to be added to the plugin dependencies of either 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
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
bnd-maven-plugin
version 6.0.0+ or maven-bundle-plugin
version 5.1.5+)The information whether a type (i.e. a class or interface) is designed as provider or consumer 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.