Documents

developing_with_eclipse.pdf

Description
Developing with Eclipse Developing with Eclipse Overview / CQ / CQ 5.5 / Developing / Development Tools / 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 differe
Categories
Published
of 10
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Transcript
  Developing with Eclipse  © 2012 Adobe Systems Incorporated.All rights reserved. Page 1 Created on 2014-05-31 Developing with Eclipse Overview / CQ / CQ 5.5 / Developing / Development Tools /  This section describes the process of setting up a local development environment for a simple CQ5 projectwith 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 developmentenvironments 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 anddeploy content to the CRX repository. (See Managing Packages Using Maven.) CREATING THE PROJECT STRUCTURE IN CQ5 Create a simple project structure in CQ5: 1.Install CQ5 on your computer. See Installing CQ5 for the procedure. In the context of this article, CQ5runs locally on port 4502. If CQ5 is already installed, ensure it is running and open the Welcome page in your web browser. 2.Open CRXDE Lite (http://localhost:4502/crx/de/ ) and create the project structure: 1.Under the /apps folder, create the nt:folder named myApp. 2.Under the myApp folder, create the nt:folder named components. 3.Under the myApp folder, create the nt:folder named templates. 4.Under the myApp folder, create the nt:folder named install.5.Click Save All3.In your browser, navigate to the Tools page of WCM (http://localhost:4502/miscadmin). 4.Select the D esigns folder, click New, and enter the following property values: ãTitle: My Application Design Page. ãName: myApp. ãTemplate: Select Design Page Template. 5.Click Create. INSTALLING FILEVAULT (VLT) FileVault (VLT) maps the content of a CRX instance to your file system. VLT functionalities are similarto those of an SVN client. You can perform check in, check out, and other file-management operations.Configuration options enable flexible representations of project content. Install VLT: 1.Copy the FileVault archive file from the cq-quickstart/opt/filevault directory of your CQ5 installation. Copyeither filevalut.tgz or filevault.zip, depending on your operating system. You can also download the latest version of FileVault from Package Share. 2.Extract the archive. 3.Add <archive-dir>/vault-cli-<version>/bin to your environment PATH so that the command files vlt orvlt.bat are accessed as appropriate. For example, <cq-installation-dir>/crx-quickstart/opt/helpers/vault-cli-2.4.8/bin 4.Open a command line shell and execute vlt --help. Make sure it displays the following help screen: -------------------------------------------------------------------------------- Jcr File Vault [version 2.4.8] Copyright 2011 by Adobe Systems Incorporated -------------------------------------------------------------------------------- Usage:  Developing with Eclipse  © 2012 Adobe Systems Incorporated.All rights reserved. Page 2 Created on 2014-05-31 vlt [options] [arg1 [arg2 [arg3] ..]] -------------------------------------------------------------------------------- Global options: -Xjcrlog Extended JcrLog options (omit argument for help) -Xdavex Extended JCR remoting options (omit argument for help) --credentials The default credentials to use --config The JcrFs config to use -v (--verbose) verbose output -q (--quiet) print as little as possible --version print the version information and exit --log-level the log4j log level -h (--help) print this help Commands: export Export the Vault filesystem import Import a Vault filesystem checkout (co) Checkout a Vault file system analyze Analyze packages status (st) Print the status of working copy files and directories. update (up) Bring changes from the repository into the working copy. info Displays information about a local file. commit (ci) Send changes from your working copy to the repository. revert (rev) Restore pristine working copy file (undo most local edits). resolved (res) Remove 'conflicted' state on working copy files or directories. propget (pg) Print the value of a property on files or directories. proplist (pl) Print the properties on files or directories. propset (ps) Set the value of a property on files or directories. add Put files and directories under version control. delete (del,rm) Remove files and directories from version control. diff (di) Display the differences between two paths. rcp Remote copy of repository content. console Run an interactive console -------------------------------------------------------------------------------- INSTALLING ECLIPSE Eclipse is open-source software that you will use to edit project source files on your file system. ApacheMaven 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. Forexample 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.  Developing with Eclipse  © 2012 Adobe Systems Incorporated.All rights reserved. Page 3 Created on 2014-05-31 CREATING THE PROJECT STRUCTURE IN ECLIPSE In this section, you create two Maven projects: ãone called UI (after User Interface) which contains the CQ5 project structure with the JSP scripts. ãthe other called Core which contains the Java code (source and compiled). The compiled code is storedin a jar file. The advantage of such a structure is that it adds modularity and autonomy to the logic of your applicationbecause each jar file (bundle) can be managed separately. Create the UI Maven Project Create the UI Maven project: 1.In Eclipse, click File > New > Other.2.In the dialog, select Maven > Maven Project and click Next.3.Select the Create a simple project option and the Use default Workspace location option, then click Next.4.Specify the following property values for the Maven project, and accept the default values for all otherproperties:ãGroup Id: com.day.cq5.myapp ãArtifact Id: ui ãName: CQ5 MyApp UI ãDescription: This is the UI module 5.Click Finish. Set the Java Compiler to version 1.5: 1.In the Project Explorer view, right-click the ui project and click Properties. 2.Select Java Compiler and set following properties to 1.5: ãCompiler compliance level ãGenerated .class files compatibility ãSource compatibility 3.Click OK. Create the filter.xml file that defines the content that VLT exports: 1.In the Project Explorer view, in the ui/src/main folder, create the content folder. 2.Under content, create the META-INF folder. 3.Under META-INF, create the vault folder. 4.Under vault, create the filter.xml file. 5.In filter.xml, copy the following code to filter.xml: <?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 /> </workspaceFilter> 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 Eclipseworkspace: <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 infilter.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.  Developing with Eclipse  © 2012 Adobe Systems Incorporated.All rights reserved. Page 4 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 JSPscripts 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 clickOK. 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 thefollowing 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 theLibraries 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 CQ5instance. It is for Unix-like systems (such as Mac OS X and Linux) and uses the 'curl' command, but mightalso 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:admincurl -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 > .classpathFILE_LIST=`cat .classpath | sed -n '/lib/s/.*WebContent\(.*\)\ .*/\1/p'`for file in $FILE_LIST; doecho Downloading $file curl -u $CRX_CREDENTIALS $CRX_URL$file -Odone To run the script: 1.Open a command line window. 2.Go to the cq5libs folder. 3.Create the file classpath.sh with the above content. 4.Run it with the following command if CQ runs on the default port (4502): $ sh ./classpath.shor with the following command if CQ runs on a different port: $ CRX_URL=http://localhost:8080 sh ./classpath.shTo find out which OSGI bundle contains the package that you need to add to your classpath: 1.Open the OSGi console and click the Configuration Status tab (http://localhost:4502/system/console/ config). 2.Select the Bundles tab. 3.Search for the package in the Exported Packages of the bundles. Create the Core Maven Project In Eclipse, create the Core Maven project: 1.Click File > New > Other. 2.In the dialog, select Maven > Maven Project and click Next. 3.Select the Create a simple project option and the Use default Workspace locations option, then clickNext. 4.Specify the following property values, and accept the default values for other properties:
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks