Apache Sling Scripting Bundle Maven Plugin

Clone this repo:
  1. a6d3a87 SLING-9338 - Allow defining an exclusion list accepting folders or files by Radu Cotescu · 4 weeks ago master
  2. 203e515 SLING-9394 - html scripts should be used to generate the resource type by Radu Cotescu · 5 weeks ago
  3. 6db8758 SLING-9379 - Make the MetadataMojo look for scripts in the default locations by Radu Cotescu · 5 weeks ago
  4. 3516ad1 SLING-9379 - Make the MetadataMojo look for scripts in the default locations by Radu Cotescu · 6 weeks ago
  5. 603a3b9 SLING-9346 - Skip files for which a script engine mapping doesn't exist by Radu Cotescu · 7 weeks ago

License Maven Central JavaDocs Build Status Test Status Quality Gate Status Coverage Bugs Vulnerabilities

Apache Sling Scripting Bundle Maven Plugin


This plugin provides support for deriving sling.resourceType Requirements and Capabilities from the file-system layout of scripts. Bundles that get extended by the org.apache.sling.scripting.bundle.tracker with these Requirements and Capabilities will have their scripts made available automatically with added versioning and dependency support.


Manually defining the Require-Capability and Provide-Capability bundle headers is error-prone and unnecessary, as they can be derived from the file-system layout required for scripts by the resolver (for the most part).


The plugin scans the javax.script file-system directory and will generate Capabilities for the scripts it finds. It expects the following layout:


From that, it will create an appropriate Provide-Capability (see the “How” section of the scripting bundle tracker) with the following extra assumptions:

  • if the name part equals the sling.resourceType or the last part of it, it is assumed to be the name of the main script; otherwise, it is assumed to be a selector;
  • if the file name is just extends it is assumed to be a file containing a single line with the resourceType used for the extends capability attribute followed by a ;version=<version-range>; in this case, the plugin will set the extends attribute to the given resourceType and generate a Require-Capability for that resourceType with the given version range;
  • if the file name is just requires the plugin will read it line by line (assuming the same syntax as for the extends file) and generate a Require-Capability for each line based on the given resourceType and version range.


As an example, let's assume the following layout:


This will generate following Provide-Capability:


For a bigger example providing several versions and using an extends file consider the following two projects:

So how do I use the plugin?

The plugin doesn't currently integrate with the maven-bundle-plugin. The generated Require-Capability and Provide-Capability headers values are simply made available via properties:


However, that makes it reasonable straightforward to use the plugin by just adding it into your build in the prepare-package phase and use the two properties in the manifest writing instructions of another plugin like the maven-bundle-plugin:


You can find an example in here.