Maven Vault Checkout Plugin (vltco) - using Maven for content checkout

07 June 2016
Lukasz Matyja
Frink_Cognifide_2016_HeaderImages_0117

Content is a very important part of each AEM/CQ application. In fact, all of our projects contain something that we call sample content. It presents all the components, templates and functionalities, but also contains some real samples of content that can be used by the client as a reference, during the content entry process. This sample content lives through almost the entire development phase, which means that it is upgraded and modified several times. However doing this manually would take too much time and could produce many issues.

AEM/CQ instance is delivered with a vlt tool. It is a command line utility which, among its multiple options, allows you to check-out content from a repository to the local file system. Unfortunately it is not integrated with Maven in any way. This aspect was very important from our perspective because Maven is a standard project building tool that we use. Furthermore, vlt tool configuration requires extra effort from each team member. So we have created Maven Vault Checkout Plugin (vltco). It is a very simple plugin that can be used in any Maven 2.x or higher project. What is worth noting, is that you do not need vlt tool on your machine to use it.

How it works?

The concept is quite simple. Maven Vault Checkout Plugin (vltco) checkouts content from a given remote repository (AEM/CQ instance) to the directory on your local machine. A FileVault checkout command is used underneath to download content. What will be downloaded depends on the Vault filter configuration.

How to use it?

First of all you need to add plugin configuration to your project. This can be done like this:

(...)<plugin>    <groupId>com.cognifide.maven.plugins</groupId>    <artifactId>vltco-maven-plugin</artifactId>    <version>0.2.0</version>    <configuration>        <uri>${aem.instance.uri}</uri>        <user>${aem.username}</user>        <password>${aem.password}</password>        <localPath>${destination.directory}</localPath>        <filter>${vault.filter.location}</filter>    </configuration></plugin>(...)

Once the plugin is added, simply execute it with following command:

mvn vltco:checkout 

Content checkout is Maven Vault Checkout Plugin (vltco) base functionality, but it also provides an extra feature. If you would like to clean your content by removing some properties, i.e. jcr:lastModified, just run below command. By default, properties from the predefined set will be removed. Of course you can define your own set using plugin configuration options.

mvn vltco:clean-checkout

These features have made Maven Vault Checkout Plugin (vltco) an easy to use tool, that is commonly used by Cognifide developers during everyday work.

Please check Cognifide GitHub repository to download the plugin and find more information and other configuration options.