Adobe CQ5 is a powerful web content management platform built on top of theJava Content Repository (JCR), Apache Sling, and OSGi in the form of Apache Felix. Adobe offers their own IDE for developing with CQ5 called CRXDE, but it has, in my eyes, a major downfall. It’s based on Eclipse. Anyone who knows me well, knows I abhor Eclipse with a passion. Instead, I choose to use IntelliJ IDEA from JetBrains. It is, in my mind, a more powerful IDE, has more comprehensive language support out of the box, and is much more user-friendly than Eclipse. I commonly tell people that IntelliJ IDEA is what Eclipse wants to be when it grows up.
Recently, I’ve been doing more and more with CQ5. As I get more into it, I want to get away from Ecipse and back to the IDE I know and love. So I went out search the Internet for documentation on how to setup IntelliJ and CQ5. There are few resources out there, but they’re all either outdated (based on old versions of IntelliJ or CQ), or incomplete. I’ve decided to document my setup here for anyone else that is interested in setting up IntelliJ and getting started with CQ5.
For the sake of argument, this post is going to assume you know what you’re doing with CQ5. If not, I highly suggest you get up to speed before proceeding.
Requirements:
Once you have your CQ5 instance up and running, we’ll want to create a new project, so to do this we’ll have to leverage CRXDE, the browser-based “lite” IDE which comes with CQ5.
- Under the “/apps” folder, create a new folder and call it “sampleApp”
- Under the “sampleApp” folder, create a folder called “components”
- Under the “sampleApp” folder, create a folder called “templates”
- Under the “sampleApp” folder, create a folder called “install”
- Click the “Save All” button
This creates our project structure in the JCR. Next, we’ll need to setup a design folder for the project. To do this, we’ll need to use the Tools section of the CQ5 admin. From the tree that is presented, choose the “Designs” folder and click “New”. Enter the following property values:
- Title: Sample App Design
- Name: sampleApp
- Template: Design Page Template
Once you have these values entered, click “Create”
Next, we will want to install the FileVault tool. Adobe outlines the process pretty well. Instructions on installing FileVault (a.k.a. VLT) can be found here. Just get vlt ready to use, don’t go through any of the SVN steps that Adobe outlines. That’s more than we want right now.
Once FileVault is setup, we’re ready to get into IntelliJ and setup the projects that we’ll need for CQ5. We’ll come back to FileVault later.
Launch IntelliJ and create a new project of type “Maven Module”. When presented with the Maven setup screen, enter the following information:

When the project is done setting up, you’ll need to create a folder under “src/main” called “content”. Under the new “content” folder, create another called “META-INF”. Within that META-INF folder, create a file called “filter.xml” with the following contents (feel free to copy & paste, and save the file when you’re done):
<?xml version="1.0" encoding="UTF-8"?>
<!-- Defines which repository items are generally included -->
<workspaceFilter version="1.0">
<filter root="/apps/myApp" />
<filter root="/etc/designs/myApp" />
<filter root="/libs/foundation" />
</workspaceFilter>
Next, we’ll revisit the vlt tool. We’ll use it to checkout the CQ5 content into our project. Open a command line tool and change the current directory to “<ProjectRoot>/src/main/content”. Execute the command vlt –credentials admin:admin co http://localhost:4502/crx. This will create the folder “jcr_root” under your “content” folder, and recursively checks out the folders we specified in the filter.xml file. It also creates some FileVault metadata files, but no need to concern yourself with those.
Once you have the files checked out into our project, you’ll need to setup the dependencies that the project will need. Adobe would have you copy the JAR files from the CQ server or setup the CQ server as an Apache Archiva server, but I find it’s easier to just setup the Adobe Maven repo within your POM, or set it up in your central proxy, and use that. In this example, we’ll just set it up as another repo in our pom.xml file by adding the following code:
<repositories>
<repository>
<id>day-central</id>
<name>Day Central (repo.adobe.com)</name>
<url>http://repo.adobe.com/archiva/repository/day-central</url>
</repository>
</repositories>
This allows us to use the following dependencies in our Maven configuration:
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-api</artifactId>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>com.day.cq</groupId>
<artifactId>cq-commons</artifactId>
<version>5.4.6</version>
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-taglib</artifactId>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-foundation</artifactId>
<version>5.4.2</version>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
<version>2.2.0</version>
</dependency>
Note: Check your Apache Felix console (http://localhost:4502/system/console/bundles) for the version numbers the use for the various components as they relate to your install
This concludes the setup of the UI portion of the project, next we’ll turn to the core, which is what you’ll use to write any additional OSGi bundles that will be needed in your UI pre. From the file menu of IntelliJ, click “New Module”. Again, we will create, from scratch, a Maven Module. The Maven settings should be as follows:

Once the project is created, you need to add some more settings to the pom.xml file for the project:
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.3</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package> com.day.cq5.sampleApp.*;version=${project.version} </Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-api</artifactId>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>com.day.cq</groupId>
<artifactId>cq-commons</artifactId>
<version>5.4.6</version>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
Note: Again, as before, make sure you check your Apache Felix console (http://localhost:4502/system/console/bundles) for the version numbers the use for the various components as they relate to your install
Once Maven has resolved the dependencies, right-click on the “src/main/java” folder and choose “New Package”. Enter a name of “com.day.cq5.sampleApp” and press OK. At this point, you have successfully setup a CQ5 project in IntelliJ IDEA 11. However, there are some caveats to how you actually make use of this. Before we get into that, I suggest you setup some shortcuts to using FileVault. You can also download a JCR plugin for IntelliJ if you like as well. That plugin may or may not help you in development.
Scripting with IntelliJ IDEA and CQ5 follows the same pattern that Adobe prescribes for scripting with Eclipse:
- Use CRXDE Lite (http://localhost:4502/crxde) to create a template and a component
- Use VLT to update the file system with the new files
- Develop the component script(s), i.e. JSPs, with IntelliJ IDEA
- Check the changes back into the JCR with VLT
Developing Java pre with IntelliJ for use in CQ5 is a bit trickier. What you’ll need to do is, in IntelliJ, add the “core” project as a dependency of the “ui” project. This will give you access to the Java pre you’re creating as you’re creating your templates for the UI. Before testing the pre on the server, you will need to install your bundle on the server. The following steps outline this process for you:
- Run the “install” maven goal for the “core” project. This will generate a jar file in the target directory of your “core” project.
- Copy that jar file to the “install” directory under the “jcr_root” directory in your “ui” project.
- Open a terminal and change the current directory to the “jcr_root” directory in your “ui” project.
- You can use the command vlt st -v to see any changes on the file system that are not in sync with the JCR.
- Place the jar file under version control with the command vlt add apps/sampleApp/install/your-jar-file-name.jar -v
- Commit the changes with vlt ci -v. This will take your template and jar file changes into the JCR.
Once your changes are into the JCR, you can view them by refreshing the CQ5 page that uses your template.
Hopefully, this will help get you up and running with IntelliJ IDEA as your IDE for CQ5 development. You will find that it is a much more powerful IDE for JSP development and is also much more fun to use than Eclipse. With a little configuration and patience, it can also be the ideal IDE for CQ5 development.