Maven: CRX Plugin automating deployments of CRX/CQ based applications

23 August 2011
Jakub Przybytek
Frink_Cognifide_2016_HeaderImages_0117
For a couple of years now, here in Cognifide, we have been successfully using CQ5 from Adobe (formerly from Day Software) in most of our projects. We've benefited from its rich functionality, stability and general market oriented approach. During those years, we have also developed our own frameworks, practices and production cycles that suit us best, but lacked an automatic deployment mechanism that would speed up our work. The main deployment process, which is a web form with a file upload mechanism, is perfect for live and integration environments, but it wasn't a surprise that we needed something easier that we could plug in to existing procedures and use every few minutes without... forcing our fingers to do too much. As a result, we have a solution that we are quite proud of and have been using it for some time now. But before we go into the details, let us examine alternative approaches that we have tested:

1. FileVault - according to Adobe (who provide it with every CQ installation package), it :
... provides your JCR repository with file system mapping and version control. It can be used to manage CQ development projects with full support for storing and versioning project code, content, configurations and so on, in standard version control systems (for example, Subversion).
We had been using it for a while before we stopped, mainly because:
  • It's not as fast as we would like it to be. It is not only a matter of running time (which could be improved), but also the fact that it is purely a command line tool and as such requires additional effort to use it. We developed some batch scripts to automate some steps, but still... it wasn't enough.
  • It was duplicating functionality of our other version control mechanism, which was SVN. Resolving conflicts in FileVault and then, in SVN was a nightmare...
But we haven't removed it completely from our tool box: FileVault is still providing us with some value while checking out or updating content from CRX repository to a local disk so we can prepare the final packages for an application.

2. Package Manager HTTP Service API - which provides a few URLs to perform such actions as: upload, install, uninstall, create, delete package; and directly on CRX repository. It seemed to be exactly what we needed, it is very well documented, but:
  • It is not easy to integrate it with Maven, it requires other tools like curl and again... batch scripting is inevitable.
  • It is not easy to understand the output of this tool. We noticed that json based requests often return successful responses even when the install command fails. It makes bug finding quite difficult. Fortunately, there are html based requests that are supported by this Api, but those simply produce too much output which cannot be understand without automated parsing tools.
The API may not be perfect, but is good enough to propose some other solution based on it. And it is exactly what we did. Let me present to you the Maven-CRX-Plugin that my colleagues developed:

Maven-CRX-Plugin
is a plugin for Maven 2.x or higher builds that automates the very last step of the development process by providing you with the ability to upload and install CRX packages into the repository. It supports continuous integration processes in development, staging or integration environments.

The plugin simply integrates some of the functionality provided by CRX API with Maven builds with additional developer-friendly parsing mechanisms that report errors details.
 Here's how it can be configured:
(...)
<plugin>
 <groupId>com.cognifide.maven.plugins</groupId>
  <artifactId>maven-crx-plugin</artifactId>
  <version>1.0.0</version>
  <configuration>
   <url>http://crx-machine:5402</url>
  <user>${crx.username}</user>
 <password>${crx.password}</password>
 </configuration>
</plugin>
(...)
And here's how it can be used:
mvn ... crx:install
Please check the Cognifide GitHub repository for more information (including configuration options). And please bear in mind that it is an early version and we appreciate all feedback received.