Escolar Documentos
Profissional Documentos
Cultura Documentos
This section describes the process of setting up a local development environment for a simple CQ5 project
with Eclipse. It then describes how to integrate logic into the project through Java coding and JSP scripting.
Lastly, it points to open source software to enable collaborative and automated developing.
Please refer to the corresponding documentation for more information on the different development
environments that are available.
The local development environment involves:
A CQ5 installation that will act as your local environment.
CRXDE Lite within the CQ5 instance to create and edit nodes and properties within the CRX repository.
FileVault (VLT), an Adobe-developed utility that maps the CRX repository to your file system.
Eclipse to edit the project source on your local file system.
Apache Maven to run local snapshot builds.
NOTE
Additionally, you can use the Content Package Maven Plugin with Apache Maven to package and
deploy content to the CRX repository. (See Managing Packages Using Maven.)
Page 1
Created on 2014-05-31
INSTALLING ECLIPSE
Eclipse is open-source software that you will use to edit project source files on your file system. Apache
Maven is also open source software that compiles Java code and stores the compiled code in a JAR file
(snapshot build).
Install Eclipse and a Maven plugin that provides the Maven functionality within Eclipse:
1. Download Eclipse - select the Eclipse IDE for Java EE Developers option.
2. Install Eclipse: extract from the downloaded zip file to your destination directory.
3. Start Eclipse:
1. Navigate to the directory into which you extracted the contents of the Eclipse installation zip file. For
example C:\Program Files\Eclipse\.
2. Double-click eclipse.exe (or Eclipse.app) to start Eclipse.
4. Open the workspace you want to use (you can either use the default or create a new workspace).
5. Create a new project and name it myApp.
6. Install the Maven Integration for Eclipse (m2e) plugin from Eclipse.org. See the instructions at http://
marketplace.eclipse.org/content/maven-integration-eclipse.
7. After installation, restart Eclipse.
2012 Adobe Systems Incorporated.
All rights reserved.
Page 2
Created on 2014-05-31
6. Save filter.xml.
Use VLT to check out the CQ5 content into your ui project:
1. In the system command line, change the current directory to the following directory in your Eclipse
workspace: <eclipse>/<workspace>/myApp/ui/src/main/content.
2. Execute the command: vlt --credentials admin:admin co http://localhost:4502/crx
This command creates the folder jcr_root under <eclipse>/<workspace>/myApp/ui/src/main/content.
This maps to the CRX root (/). Under jcr_root the following files and folders are created, as defined in
filter.xml:
apps/myApp
etc/designs/myApp
It also creates two files, config.xml and settings.xml in <eclipse>/<workspace>/myApp/ui/src/main/
content/META-INF/vault. VLT uses these files.
2012 Adobe Systems Incorporated.
All rights reserved.
Page 3
Created on 2014-05-31
In the ui Eclipse project, create a link to the apps folder that you just checked out. This link enables your JSP
scripts to reference the files:
1. Right-click ui, select New, then Folder.
2. In the dialog box, click Advanced and select Link to alternate location.
3. Click Browse, specify <eclipse>/<workspace>/myApp/ui/src/main/content/jcr_root/apps, and then click
OK.
4. Click Finish.
The apps folder appears below the ui project in the Project Explorer view.
Add the CQ and Sling libraries (.jar files) that you require to the Eclipse classpath. Copy the libraries from the
repository to a local folder, and add the folder to the Eclipse classpath. In this exercise, you reference the
following libraries:
/libs/sling/install
/libs/cq/commons/install
/libs/wcm/core/install
Obtain the libraries using WebDAV:
1. In your file system, create a CQ5 libraries folder called cq5libs. This folder can be created anywhere.
2. Map the repository to your file system using a WebDAV client.
3. Copy all of the .jar files from the following directories to your cq5libs directory:
/libs/sling/install
/libs/cq/commons/install
/libs/wcm/core/install
4. In Eclipse, right-click the ui project and click Build Path > Configure Build Path. In the dialog select the
Libraries tab.
5. Click Add External JARS, browse to the cq5libs folder and select all the JAR files, then click Open.
6. Click OK.
Instead of WebDAV, you can use a script. The following script downloads all the libraries from a CQ5
instance. It is for Unix-like systems (such as Mac OS X and Linux) and uses the 'curl' command, but might
also succeed running it on Windows with Cygwin (for unix emulation):
#!/bin/sh
[ -z "$CRX_URL" ] && CRX_URL=http://localhost:4502
[ -z "$CRX_CREDENTIALS" ] && CRX_CREDENTIALS=admin:admin
curl -H x-crxde-version:1.0 -H x-crxde-os:mac -H x-crxde-profile:default -u $CRX_CREDENTIALS
$CRX_URL/bin/crxde.classpath.xml > .classpath
FILE_LIST=`cat .classpath | sed -n '/lib/s/.*WebContent\(.*\)\".*/\1/p'`
for file in $FILE_LIST; do
echo "Downloading $file"
curl -u $CRX_CREDENTIALS $CRX_URL$file -O
done
Page 4
Created on 2014-05-31
Page 5
Created on 2014-05-31
If the dependencies are not stored in the local Maven repository, compiler errors appear in the pom.xml file.
Note: Perform the following procedure only if the three CQ5 artifacts are not globally deployed for the project
on a public Maven repository (such as using Apache Archiva).
Deploy the CQ5-specific artifacts as defined in pom.xml (cq-wcm-api, cq-commons and org.apache.sling.api)
to the local Maven repository:
1. In your file system, copy the file cq-wcm-api-{version}.jar located at cq5libs/wcm (you have created those
folders before) into <your-user-dir>/.m2/repository/com/day/cq/wcm/cq-wcm-api/{version} (create the
folders if they do not exist).
2. In your file system, copy the file cq-commons-{version}.jar located at cq5libs/cq (you have created those
folders before) into <your-user-dir>/.m2/repository/com/day/cq/cq-commons/{version} (create the folders
if they do not exist).
3. In your file system, copy the file org.apache.sling.api-{version}.jar located at cq5libs/sling (you have
created those folders before) into <your-user-dir>/.m2/repository/org/apache/sling/org.apache.sling.api/
{version} (create the folders if they do not exist).
Set the Java Compiler to version 1.5:
1. Right-click the core project, select Properties.
2. Select Java Compiler and set following properties to 1.5:
Compiler compliance level
Generated .class files compatibility
Source compatibility
3. Click OK.
4. In the dialog window, click Yes.
Create the package com.day.cq5.myapp that will contain the Java classes under the core/src/main/java
folder:
1. Under core, right-click the src/main/java folder and click New > Package.
2. Enter the name com.day.cq5.myapp and click Finish.
Page 6
Created on 2014-05-31
You can define VLT commands as External Tools in Eclipse to run the commands from within
Eclipse.
Create and compile a Java class. Package the class in a JAR file that can be deployed to CQ.
Page 7
Created on 2014-05-31
Page 8
Created on 2014-05-31
4. To update the repository, open a system command line window and change the current directory to
<eclipse>/<workspace>/myApp/ui/src/main/content/jcr_root.
5. To see the changes to the file system, execute the following command:vlt st -v
6. To commit the contentpage.jsp file to the repository, execute the following command:vlt ci -v
Subversion (SVN) to manage a central repository where all the developers involved in the project can
commit and retrieve the code and the content they generate on their local instance.
Apache Archiva to centrally store and retrieve the project libraries.
Apache Continuum to automate the build process.
Page 9
Created on 2014-05-31
configuring local developer accounts to obtain access to the snapshots and full releases. Archiva can be
found here.
When setting up Archiva for a CQ project the only step that is specific to CQ itself is initially populating the
repository with the artifacts needed for CQ development. To acquire the full set of libraries you can use the
same method as described above in point #7 of Create The UI Maven Project.
You can use the same script as shown there (and reproduced here):
#!/bin/sh
[ -z "$CRX_URL" ] && CRX_URL=http://localhost:4502
[ -z "$CRX_CREDENTIALS" ] && CRX_CREDENTIALS=admin:admin
curl -H x-crxde-version:1.0 -H x-crxde-os:mac -H x-crxde-profile:default -u $CRX_CREDENTIALS
$CRX_URL/bin/crxde.classpath.xml > .classpath
FILE_LIST=`cat .classpath | sed -n '/lib/s/.*WebContent\(.*\)\".*/\1/p'`
for file in $FILE_LIST; do
echo "Downloading $file"
curl -u $CRX_CREDENTIALS $CRX_URL$file -O
done
This script simply downloads all the libraries from your CQ installation. By deploying these libraries to
your Archiva repository, you can make them available to your whole development team. To deploy the
downloaded files to Archiva, see the Archiva documentation here.
Page 10
Created on 2014-05-31