Generating aggregate content-packages for CRX

December 11, 2011

Maybe obvious, but just to make sure: this is hopelessly outdated. The maven-vault-plugin has been superseded by the content-package-maven-plugin and a detailed description of how to use Maven for CQ / AEM Projects is available on the AEM Documentation Site, by yours truly.

Your typical CQ or CRX project is multi-module, right? You have the typical collection of modules = artifacts = bundles and content packages: content, samplecontent, uiapp, core, taglib – you name them.

For cutting releases, it’s convenient to have just a single, defined artifact that aggregates all project artifacts into one, has a single version number, and is easily installed.

Including OSGi bundles for installation in a content package is easy enough, including content packages in other content packages on the other hand is not so common (but also easy enough). Here’s how it works:

configure maven-vault-plugin:

As always, configure maven-vault-plugin. Just use a different group than for your other packages, e.g. by appending ” Releases”. Also, set your module’s packaging to content-bundle.

    com.day.jcr.vault
    maven-vault-plugin
    true
 
        MyProject Releases
        true
 
        true
        true
 
        ${project.build.directory}/${project.build.finalName}.zip
 
        ${project.version}

add the packages to include as dependencies:

Just list them as regular dependencies, with the appropriate type (typically content-bundle).

        my-project-groupid
        uiapp
        ${project.version}
        content-package
 
 
        my-project-groupid
        content
        ${project.version}
        content-package
 
 
        my-project-groupid
        samplecontent
        ${project.version}
        content-package

copy the packages into the aggregate package:

Configure maven-dependency-plugin to copy the dependencies to /etc/packages/MyProject as shown below.
You need to list out your artifacts in includeArtifacts.

    org.apache.maven.plugins
    maven-dependency-plugin
 
 
            copy-packages
            prepare-package
 
                copy-dependencies
 
 
 
                    ${project.build.directory}/vault-work/jcr_root/etc/packages/MyProject
 
                true
 
                    uiapp,samplecontent,content

adjust your vlt filter config (as usual):

Of course, your aggregate package needs to have an appropriate filter.xml, like so:

<!--?xml version="1.0" encoding="UTF-8"?-->

set the assembly package configuration (as usual):

    org.apache.maven.plugins
    maven-assembly-plugin
 
 
            package-zip
            package
 
                single
 
 
                false
 
                    src/main/assembly/package.xml
    zip
 
        zip
 
    false
 
 
 
 
            ${project.build.directory}/vault-work

That’s it – now build your bundle with mvn package and you’ll get a neatly wrapped content bundle that contains your content bundles.

handling OSGi bundles

You can include your OSGi bundles directly in this bundle as well, or you can include them in your inner content bundles. Either way works. Above example takes the latter approach (so it cannot be seen and the examples are cleaner :)

adding metadata

As this is a regular content bundle, you can easily add custom content with release information, e.g. a file /etc/myapp-releaseinfo.txt that contains build number, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *


*