Embedding OSGi Bundles

The embed-bundles goal is used to programmatically add OSGi bundles to the vault package. By default, it will execute once during the prepare-package phase. Bundles will be inserted into the package at the path specified by the bundleInstallPath configuration parameter, with the effective node name matching the pattern [articleId]-[version].jar.

Different bundles may be embedded at different bundleInstallPaths in the same package by using multiple executions of this goal, each with their own bundleInstallPath value.

The vault-inf goal will modify the workspaceFilter to include the embedded bundle paths under an appropriate filter root if it is not already included.

Embedding Sub-packages

The embed-packages goal is used to programmatically add sub-packages to the vault package, which will be installed by the CRX Package Manager upon extraction of the parent package. Sub-packages are embedded under /etc/packages at the path determined by their PackageId, which is constructed based on the group, name, and version package properties present within the zip binary at META-INF/vault/properties.xml.

The vault-inf goal will modify the workspaceFilter to include the embedded package paths under an /etc/packages filter root.

Embedding InstallHooks

For more complex package installs, it may be necessary to implement one or more InstallHooks. A valid InstallHook is a jar with a Main-Class manifest attribute whose value references a class in the jar that implements com.day.jcr.vault.packaging.InstallHook.

The embed-hooks goal will embed such jars under META-INF/vault/hooks, as expected by CRX Package Manager.

Example POM with embedded dependencies

The following example illustrates how to configure your POM to embed each type of dependency: bundles, packages, and install hooks. Notice that the embed configurations reference project dependencies by artifactId, which is similar to the convention used by the maven-bundle-plugin.

                
<project>
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>example-ui</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!-- be sure to specify the packaging type as 'vltpack' -->
    <packaging>vltpack</packaging>

    <dependencies>
        <dependency>
            <groupId>org.example</groupId>
            <artifactId>example-bundle</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.example</groupId>
            <artifactId>example-package</artifactId>
            <version>1.0-SNAPSHOT</version>
            <!-- vltpack deploys CRX packages to maven repositories with a ".zip" extension -->
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.example</groupId>
            <artifactId>example-hook</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build>

        <plugins>
            <plugin>
                <groupId>net.adamcin</groupId>
                <artifactId>vltpack-maven-plugin</artifactId>
                <version>1.0.0</version>
                <extensions>true</extensions>

                <!-- project dependencies are referenced by
                artifactId in the plugin configuration -->
                <configuration>
                    <embedBundles>
                        <bundle>example-bundle</bundle>
                    </embedBundles>
                    <embedPackages>
                        <package>example-package</package>
                    </embedPackages>
                    <embedHooks>
                        <hook>example-hook</hook>
                    </embedHooks>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>