Context-Aware Configuration does not work
Expected Behaviour
a Sling Context-Aware configuration can be used
Actual Behaviour
An interface annotated as org.apache.sling.caconfig.annotation.Configuration is not found by the bnd-process
The issue can be fixed, if the current bnd-configuration (main pom.xml)
# does NOT work
-plugin org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin
-plugin org.apache.sling.bnd.models.ModelsScannerPlugin
is changed to
# does work
-plugin.caconfig org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin
-plugin.models org.apache.sling.bnd.models.ModelsScannerPlugin
see merged bnd-instructions (chapter 33.2 Merged Instructions at https://bnd.bndtools.org/chapters/820-instructions.html)
alternatively all plugins can be specified in a single line
# works too
-plugin org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin,org.apache.sling.bnd.models.ModelsScannerPlugin
In the current version only the ModelsScannerPlugin is used. By changing the order of the lines, only the ConfigurationClassScannerPlugin is used. So the last -plugin instruction wins.
Steps to Reproduce
Add a Context-aware configuration to core, and the built bundle should have 2 Manifest-Headers
- Sling-ContextAware-Configuration-Classes:
- Sling-Model-Classes:
Platform and Version
AEMaaCS, MacOS w. M1 chip - but probably all platforms
PS: I could create a Pull-Request, which also includes a sample CA-Config.
kind regards, Alexander Berndt
I have replicated this issue. It is worth nothing that projects like AEM WCM Core Components are still using the maven-bundle-plugin and not bnd-maven-plugin.
Either of the solutions proposed by @alberndt works.
Bnd instructions should use the format outlined in https://bnd.bndtools.org/chapters/820-instructions.html:
bnd instruction is a property that starts with a minus sign (‘-‘)
That implies using the properties format <name>: <value>