Adobe Content Package Maven Plugin adobe-content-package-maven-plugin
Use the Adobe Content Package Maven plugin to integrate package deployment and management tasks into your Maven projects.
The deployment of the constructed packages to AEM is performed by the Adobe Content Package Maven plugin and enables the automation of tasks normally performed using AEM Package Manager:
- Create new packages from files in the file system.
- Install and uninstall packages on AEM.
- Build packages that are already defined on AEM.
- Obtain a list of packages that are installed on AEM.
- Remove a package from AEM.
This document details how to use the Maven to manage these tasks. However it is also important to understand how AEM projects and their packages are structured.
- The
content-package-maven-plugin
no longer supports packaging from release 1.0.2. - This article describes the deployment of the constructed packages to AEM is performed by the Adobe Content Package Maven plugin.
Packages and the AEM Project Structure aem-project-structure
AEM as a Cloud Service adheres to the latest best practices for package management and project structure as implemented by the latest AEM Project Archetype.
Obtaining the Content Package Maven Plugin obtaining-the-content-package-maven-plugin
The plugin is available from the Maven Central Repository.
Content Package Maven Plugin Goals and Parameters
To use the Content Package Maven Plugin, add the following plugin element inside the build element of your POM file:
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<version>1.0.4</version>
<configuration>
<!-- parameters and values common to all goals, as required -->
</configuration>
</plugin>
To enable Maven to download the plugin, use the profile provided in the Obtaining the Content Package Maven Plugin section on this page.
Goals of the Content Package Maven Plugin 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 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 parameter-prefix
Unless otherwise noted, the plugin goals and parameters use the vault
prefix, as in the following example:
mvn content-package:install -Dvault.targetURL="https://192.168.1.100:4502/crx/packmgr/service.jsp"
Proxies proxies
Goals that use proxies for AEM 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 Parameters section.
Common Parameters common-parameters
The parameters in the following table are common to all goals except when noted in the Goals column.
failOnError
boolean
false
true
causes the build to fail when an error occurs. A value of false
causes the build to ignore the error.package
name
String
build
: Yes, install
: No, rm
: Yesbuild
: No default, install
: The value of the artifactId
property of the Maven projectls
password
String
admin
package
serverId
String
package
targetURL
String
http://localhost:4502/crx/packmgr/service.jsp
package
timeout
int
5
package
useProxy
boolean
true
true
causes Maven to use the first active proxy configuration found to proxy requests to the Package Manager.package
userId
String
admin
package
verbose
boolean
false
package
build build
Builds a content package that is already defined on an AEM instance.
Parameters parameters
All parameters for the build goal are described in the Common Parameters section.
install install
Installs a package in the repository. Execution of this goal does not require a Maven project. The goal is bound to the install
phase of the Maven build lifecycle.
Parameters parameters-1
In addition to the following parameters, see the descriptions in the Common Parameters section.
artifact
String
artifactId
property of the Maven projectgroupId:artifactId:version[:packaging]
artifactId
String
groupId
String
groupId
of the artifact to installinstall
boolean
true
localRepository
org.apache.maven.artifact.repository.ArtifactRepository
localRepository
system variablepackageFile
java.io.File
packaging
String
zip
pomRemoteRepositories
java.util.List
remoteArtifactRepositories
property that is defined for the Maven projectproject
org.apache.maven.project.MavenProject
repositoryId
(POM), repoID
(command line)String
temp
repositoryUrl
(POM), repoURL
(command line)String
ls ls
Lists the packages that are deployed to Package Manager.
Parameters parameters-2
All parameters of the ls goal are described in the Common Parameters section.
rm rm
Removes a package from Package Manager.
Parameters parameters-3
All parameters of the rm goal are described in the Common Parameters section.
uninstall uninstall
Uninstalls a package. The package remains on the server in the uninstalled state.
Parameters parameters-4
All parameters of the uninstall goal are described in the Common Parameters section.
package 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 parameters-5
In addition to the following parameters, see the description of the name
parameter in the Common Parameters section.
archive
org.apache.maven.archiver.MavenArchiveConfiguration
builtContentDirectory
java.io.File
dependencies
java.util.List
embeddedTarget
java.lang.String
embeddeds
java.util.List
failOnMissingEmbed
boolean
false
true
causes the build to fail when an embedded artifact is not found in the project dependencies. A value of false
causes the build to ignore such errors.filterSource
java.io.File
filters
com.day.jcr.vault.maven.pack.impl.DefaultWorkspaceFilter
filter.xml
file. See the Using Filters section below.finalName
java.lang.String
finalName
defined in the Maven project (build phase).zip
file extensiongroup
java.lang.String
groupID
defined in the Maven projectgroupId
of the generated content package which is part of the target installation path for the content packageoutputDirectory
java.io.File
prefix
java.lang.String
project
org.apache.maven.project.MavenProject
properties
java.util.Map
properties.xml
file. These properties cannot overwrite the following predefined properties: group
(use group
parameter to set), name
(use name
parameter to set), version
(use version
parameter to set), description
(set from the project description), groupId
(groupId
of the Maven project descriptor), artifactId
(artifactId
of the Maven project descriptor), dependencies
(use dependencies
parameter to set), createdBy
(the value of the user.name
system property), created
(the current system time), requiresRoot
(use requiresRoot
parameter to set), packagePath
(automatically generated from the group and package name)requiresRoot
boolean
requiresRoot
property of the properties.xml
file.subPackages
java.util.List
version
java.lang.String
workDirectory
java.io.File
Using filters using-filters
Use the filters element to define the package content. The filters are added to the workspaceFilter
element in the META-INF/vault/filter.xml
file of the package.
The following filter example shows the XML structure to use:
<filter>
<root>/apps/myapp</root>
<mode>merge</mode>
<includes>
<include>/apps/myapp/install/</include>
<include>/apps/myapp/components</include>
</includes>
<excludes>
<exclude>/apps/myapp/config/*</exclude>
</excludes>
</filter>
Import Mode import-mode
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.
When the filter contains no mode
element, the default value of replace
is used.
help help
Parameters parameters-6
detail
boolean
false
goal
String
indentSize
int
2
lineLength
int
80
Including a Thumbnail Image or Properties File in the Package 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.
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:
<build>
<resources>
<!-- vault META-INF resources (thumbnail and so on) -->
<resource>
<directory>${basedir}/src/main/content/META-INF</directory>
<targetPath>../vault-work/META-INF</targetPath>
</resource>
</resources>
</build>
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:
<build>
<resources>
<!-- thumbnail only -->
<resource>
<directory>${basedir}/src/main/content/META-INF/vault/definition</directory>
<targetPath>../vault-work/META-INF/vault/definition</targetPath>
</resource>
</resources>
</build>
Using the AEM Project Archetype to Generate AEM Projects using-archetypes
The latest AEM Project Archetype implements the best-practice package structure for both on-premises and AMS implementations and is recommended for all AEM projects.