Use the Content Package Maven plugin to integrate package management tasks into your Maven projects. The plugin goals and parameters enable you to automate many of the tasks that you would normally perform using the Package Manager page or the FileVault command line:

Create new packages from files in the file system.

Install and uninstall packages on the CRX or CQ server.

Build packages that are already defined on the server.

Obtain a list of packages that are installed on the server.

Remove a package from the server.

Adding the Content Package Maven Plugin to the POM File

To use the Content Package Maven Plugin, add the following plugin element inside the build element of your POM file:

Goals of the Content Package Maven Plugin

The goals and goal parameters that the Content Package plugin provides are described in the sections that follow. Parameters that are described in the Common Parameters section can be used for most of the goals. Parameters that apply to one goal are described in the section for that goal.

Plugin Prefix

The plugin prefix is content-package. Use this prefix to execute a goal from the command line, as in the following example:

mvn content-package:build

Parameter Prefix

Unless otherwise noted, the plugin goals and parameters use the vault prefix, as in the following example:

Goals that use proxies for the CRX or CQ server use the first valid proxy configuration found in the Maven settings. If no proxy configuration is found, no proxy is used. See the useProxy parameter in the Common Settings section.

Common Parameters

The parameters in the following table are common to all goals except when noted in the Goals column.

Name

Type

Required

Default Value

Description

Goals

failOnError

boolean

No

false

A value of true causes the build to fail when an error occurs. A value of false causes the build to ignore the error.

All goals except package.

name

String

build: Yes
install: No
rm: Yes

Build: No default.
install: The value of the artifactId property of the Maven project.

The name of the package to act on.

All goals except ls.

password

String

Yes

admin

The password used for authentication with the CRX server.

All goals except package.

serverId

String

No

The server ID from which to retrieve the user name and password for authentication.

All goals except package.

targetURL

String

Yes

http://localhost:4502/
crx/packmgr/
service.jsp

The URL of the HTTP service API of the CRX package manager.

All goals except package.

timeout

int

No

5

The connection timeout for communicating with the package manager service, in seconds.

All goals except package.

useProxy

boolean

No

true

Determines whether to use proxy configurations from the Maven settings file. A value of true causes the use of the first active proxy configuration found to proxy requests to the package manager. A value of false causes no proxy to be used.

install

Installs a package in the CRX respository. Execution of this goal does not require a Maven project. The goal is bound to the Install phase of the Maven build lifecycle.

Parameters

In addition to the following parameters, see the descriptions in the Common Parameters section.

Name

Type

Required

Default Value

Description

artifact

String

No

The value of the artifactId property of the Maven project.

A string of the form groupId:artifactId:version[:packaging].

artifactId

String

No

The ID of the artifact to install

groupId

String

No

The groupId of the artifact to install

install

boolean

No

true

Determines whether to unpack the package automatically when it is uploaded. A value of true unpacks the package, and false does not unpack the package.

localRepository

org.apache.maven.
artifact. repository.
ArtifactRepository

No

The value of the localRepository system variable.

The local Maven repository. You cannot configure this paramter using the plugin configuration. The system property is always used.

packageFile

java.io.File

No

The primary artifact that is defined for the Maven project.

The name of the package file to install.

packaging

String

No

zip

The type of packaging of the artifact to install

pomRemoteRepositories

java.util.List

Yes

The value of the remoteAtifactRepositories property that is defined for the Maven project.

This value cannot be configured using the plugin configuration. The value must be specified in the project.

project

org.apache.maven.
project.MavenProject

Yes

The project for which the plugin is configured.

The Maven project. The project is implicit because the project contains the plugin configuration.

repositoryId (POM)
repoID (command line)

String

No

temp

The ID of the repository from which the artifact is retrieved. In a POM, use repositoryID. In a command line, use repoID.

repositoryUrl (POM)
repoURL (command line)

String

No

The URL of the repository from which the artifact is retrieved. In a POM, use repositoryURL. In a command line, use repoURL.

version

String

No

The version of the artifact to install.

Example

The following example creates a package that contains the workflow-mbean OSGi bundle (see the example for the build goal) and then installs the package. Because the install goal is bound to the package install phase, the following command executes the install goal:

package

Creates a content package. The default configuration of the package goal includes the contents of the directory where compiled files are saved. The execution of the package goal requires that the compile build phase has completed. The package goal is bound to the package phase of the Maven build lifecycle.

Parameters

In addition to the following parameters, see the description of the name parameter in the Common Parameters section.

The mode element defines how content is the repository is affected when the package is imported. The following values can be used:

Merge: Content in the package that is not already in the repository is added. Content that is in both the package and the repository is unchanged. No content is removed from the repository.

Replace: Content in the package that is not in the repository is added to the repository. Content in the repository is replaced with matching content in the package. Content is removed from the repository when it does not exist in the package.

Update: Content in the package that is not in the repository is added to the repository. Content in the repository is replaced with matching content in the package. Existing content gets removed from the repository.

When the filter contains no mode element, the default value of replace is used.

Example

The following example creates a package that contains the workflow-mbean OSGi bundle. The POM file identifies the jcr_root directory as the value of the builtContentDirectory property. The jcr_root directory contains the bundle JAR file in the directory structure that mirrors the repository:

jcr_root/apps/myapp/install/workflow-mbean-0.03-SNAPSHOT.jar

Because the goal is bound to the package build phase, the following command executes the package goal:

help

Parameters

Determines whether to display all settable properties for each goal. A value of true displays all settable properties.

goal

String

No

The name of the goal for which to show help. If no value is specified, help for all goals is displayed.

indentSize

int

No

2

The number of spaces to use for the indentation of each level. If you specify a value, the value should be positive.

lineLength

int

No

80

The maximum length of a display line. If you specify a value, the value should be positive.

Obtaining the Content Package Maven Plugin

The plugin is available from the public Adobe repository. To download the plugin, add the following Maven profile to your Maven settings file and activate it. When you use a Maven command, the plugin is downloaded to your local repository if needed.

Nota:

The Adobe Public Releases repository is not browsable, so that navigating to the repository URL using your web browser results in a Not Found error. However, Maven is able to access the repository directories.

Including a Thumbnail Image or Properties File in the Package

Replace the default package configuration files to customize the package properties. For example, include a thumbnail image to distinguish the package in Package Manager and Package Share.

In the package, FileVault-specific files are located in the /META-INF/vault folder. The source files can be located anywhere in your file system. In the POM file, define build resources to copy the source files to the target/vault-work/META-INF for inclusion in the package.

The following POM code adds the files in the META-INF folder of the project source to the package:

The following POM code adds only a thumbnail image to the package. The thumbnail image must be named thumbnail.png, and must be located in the META-INF/vault/definition folder of the package. In this example, the source file is located in the /src/main/content/META-INF/vault/definition folder of the project:

Archetype artifacts are available from the Adobe public Maven repository. To download and execute an archetype, identify the archetype and the Adobe repository using the parameters of the Maven archetype:generate command:

The Maven archetype plugin uses interactive mode in the shell or command prompt to collect information about your project. The information that you provide is used to configure various project properties, such as folder names and artifact ID's.

POM files

The generated POM files include commands for compiling code, creating bundles, and deploying them to CQ in packages. The groupID, artifactId, version, and name properties of the Maven project are automatically populated using the values that you provide to the Maven archetype:generate interactive prompt.

You may want to change the the following default values in the generated pom.xml file:

The CQ server name or IP address: The default value is localhost. The crx.host element below project/properties contains this value.

The port number for the CQ server: The default value is 4502. The crx.port element below project/properties contains this value.

The version of Content Package Maven Plugin: Use the latest version as the content of the version element for the plugin with artifactId of content-package-maven-plugin. The default value is 0.0.24.

Using the archetypes

In a shell window or command prompt, enter the Maven archetype:generate command. When prompted, provide values for the remaining parameters.

For information about each parameter, refer to the section for the archetype that you are using.

Use a text editor to open the pom.xml file and edit default values according to your requriements.

Populate the generated folders with resources.

Enter the mvn clean install command.

simple-content-package-archetype

Creates a maven project that is suitable for installing resources for a simple CQ application. The folder structure is that used below the /apps folder of the CQ repository. The POM defines commands for packaging the resources that you place in the folders and installing the packages on the CQ server.

multimodule-content-package-archetype

Creates a maven project that includes the folder structure for developing a CQ application and installing resources to the server.

The bundle folder contains the folder structure that stores the Java and JUnit source files that you develop. The pom.xml file in this folder creates the OSGi bundle. The following values in the POM identify the artifact and the bundle:

artifactID: ${artifactID}-bundle.

Bundle-SymbolicName: ${groupId}.${artifactId}-bundle.

${artifactID} and ${groupId} are the values that you provide for these parameters when executing the archetypes.

The content folder contains the resources that are installed to the CQ server. The value of artifactID is ${artifactID}multimodule-bundle.

The parent folder contains the parent POM that manages Maven plugins and dependencies.