Fork me on GitHub


The plugin can be used either as a regular Maven plugin or as a bnd plugin. Its purpose is to extract the capabilities required for packaging the scripts (precompiled or not) into an OSGi bundle. Both versions of the plugin can be used for OSGi bundle projects, however the bnd plugin can also be used with FileVault content package projects.

Both versions of the plugin will, by default, look for scripts in two project directories:

  1. src/main/scripts - this folder will contain scripts that will be pre-compiled
  2. src/main/resources/javax.script - this folder will contain scripts that will be embedded as is

The structure in these source directories should then follow the normal way of structuring scripts in an Apache Sling application. For more details, check the Sling Scripting page. In addition to the normal way of structuring scripts in the file tree, the plugin provides some additional features:

  1. Resource Type Versioning
    This works by putting the scripts in a folder that follows this simple naming convention: <resourceType>/<version>/. The <version> should be a valid semantic version (e.g. 1.0.0)

  2. Defining explicit extends relationships (similar to the sling:resourceSuperType property)
    An extends file in the resource type folder (versioned or not) allows defining this explicit relationship. This file must contain 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. To generate an optional capability header (when the bundled script extends from a non-bundle, resource script), append ;resolution:=optional to the line. The line must comply with the OSGI common header syntax from OSGI Core R7 §3.2.4.

  3. Defining an explicit requirement, without an inheritance relationship (e.g. delegation to another resource type)
    A requires file (assuming the same conventions and syntax as for the extends file) will generate a Require-Capability for each line based on the given resourceType and version range.

  4. The Resource Type can have the form of a path or of a Java package name (e.g. com.mydomain.components.image). When the resource type is defined as a package name, the resource type label will be the last subpackage (i.e. for com.mydomain.components.image, the resource type label will be image).

Starting with version 0.5.0, the plugin will mark the requirements which are not satisfied by the analysed project as optional; classpath dependencies are not checked for provided capabilities. If you want to generate mandatory requirements, set the missingRequirementsOptional flag to false.

Defining scripts

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


This will generate following Provide-Capability:


For more complex examples head over to

Configure Maven Plugin

When used as a Maven plugin, the generated Require-Capability and Provide-Capability headers values are made available via Maven project properties:


That makes it reasonably straightforward to use the plugin by just adding it into your build and use the two properties in the manifest writing instructions of another plugin like the maven-bundle-plugin:


The osgi.extender requirement is mandatory to have the bundle wired up to the Apache Sling Servlets Resolver, but this should be manually defined by the developers, so that their bundle is correctly wired up to whatever version of the Servlets Resolver is available on the destination platform.