Plugin Documentation

Goals available for this plugin:

Goal Description
sling:deploy Deploy a JAR representing an OSGi Bundle to a Sling OSGi Bundle Repository. This method posts the bundle built by maven to the OSGi Bundle Repository. The plugin uses a multipart/format-data POST request to just post the file to the URL configured in the obr property.
sling:deploy-file Deploy a JAR representing an OSGi Bundle to a Sling OSGi Bundle Repository. This method posts the bundle referenced via sling.file to an OSGi Bundle Repository accepting the bundle. The plugin uses a multipart/format-data POST request to just post the file to the URL configured in the obr property.
sling:fsmount Creates OSGi configurations for the Apache Sling File System Resource Provider.
sling:fsunmount Removes OSGi configurations for the Apache Sling File System Resource Provider.
sling:generate-adapter-metadata Build adapter metadata (JSON) for the Web Console Plugin at /system/console/status-adapters and /system/console/adapters from classes annotated with adapter annotations.
sling:help Display help information on maven-sling-plugin.
Call mvn sling:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.
sling:install Install an OSGi bundle to a running Sling instance. The plugin places an HTTP POST request to Felix Web Console. It's also possible to HTTP PUT instead of POST leveraging the WebDAV bundle from Sling. Since version 2.1.8 you can also leverage the the Sling POST servlet for that The chosen method depends on the parameter deploymentMethod.

Intermediate Node Creation

For all deploymentMethods except WebDAV the bundle is not directly deployed within the OSGi container, but rather being uploaded to the JCR and from there on being picked up by the JCR Installer Provider asynchronously, which takes care of deploying it in the OSGi container. For both other deployment methods, intermediate nodes (i.e. inexisting parent nodes) are automatically created. The primary type of those intermediate nodes depend on the deployment method.

  • WebDAV, uses the configured collection node type, by default sling:Folder (see also WebDAV Configuration)
  • SlingPostServlet, uses internally ResourceResolverFactory.create(...) without setting any jcr:primaryType. Therefore the JcrResourceProviderFactory will call Node.addNode(String relPath) which determines a fitting node type automatically, depending on the parents node type definition (see Javadoc). So in most of the cases this should be a sling:Folder, as this is the first allowed child node definition in sling:Folder. This only may differ, if your existing parent node is not of type sling:Folder itself.
sling:install-file Install an OSGi bundle to a running Sling instance.
sling:uninstall Uninstall an OSGi bundle from a running Sling instance. The plugin places by default an HTTP POST request to Felix Web Console to uninstall the bundle. It's also possible to use HTTP DELETE leveraging the WebDAV bundle from Sling. or the Sling POST servlet to uninstall the bundle. The chosen method depends on the parameter deploymentMethod.
sling:validate The validate goal checks the JSON code of a bundle.

System Requirements

The following specifies the minimum requirements to run this Maven plugin:

Maven 3.0.4
JDK 1.7
Memory No minimum requirement.
Disk Space No minimum requirement.

Usage

You should specify the version in your project's plugin configuration:

<project>
  ...
  <build>
    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.sling</groupId>
          <artifactId>maven-sling-plugin</artifactId>
          <version>2.3.2</version>
        </plugin>
        ...
      </plugins>
    </pluginManagement>
    <!-- To use the plugin goals in your POM or parent POM -->
    <plugins>
      <plugin>
        <groupId>org.apache.sling</groupId>
        <artifactId>maven-sling-plugin</artifactId>
        <version>2.3.2</version>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

For more information, see "Guide to Configuring Plug-ins"