Wednesday, May 29, 2013

How To Use Apache Maven to Build and Deploy OSGi Bundles to CQ?

Apache Maven is a successor to Apache Ant and is a key tool for CQ development.  Most of the heavy lifting in CQ is done by Java POJOs built and packaged as OSGi bundles and deployed to Apache Felix, which is CQ’s OSGi runtime framework.

There’s an outstanding 8-part introductory video tutorial series on Maven by Koushik Kothagal on YouTube.  That’s a great place to start to learn about Maven.

Here are the steps to get you set up:

1) If you haven’t done so yet, install and configure a 1.6 JDK.  Instructions here.

2) Download Apache Maven

3) Unzip to a folder.  Eg.  C:\Programs\Apache\Maven

4) Create separate folder for the Maven Repository - separate so that you can update Maven with a newer version without affecting the repo.  Eg. C:\Programs\Apache\Maven\local_repo

5) Configure system environment variables M2_HOME(C:\Programs\Apache\Maven\apache-maven-3.0.4) and M2_REPO(C:\Programs\Apache\Maven\local_repo)

6) Add the /bin folder of Maven to the beginning of the existing system environment variable Path as e.g. %M2_HOME%\bin;

7) Start a command prompt and test whether maven is working.

mvn —version

You should get a response such as this:

Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)
Maven home: C:\Programs\Apache\Maven\apache-maven-3.0.4
Java version: 1.6.0_31, vendor: Sun Microsystems Inc.
Java home: C:\Programs\Java64-6\jre
Default locale: en_US, platform encoding: Cp1252
OS name: “windows 7”, version: “6.1”, arch: “amd64”, family: “windows”

8) Copy the Maven configuration file settings.xml from C:\Programs\Apache\Maven\apache-maven-3.0.4\conf\ to your Windows user profile.  Eg. C:\Users\JAYAN\.m2\

7) Edit settings.xml to configure the local repository.  Eg:

<localRepository>C:\Programs\Apache\Maven\local_repo</localRepository>

8) Sample Maven settings for Adobe’s public repository is available here.  Also see this from Adobe on integrating Adobe CQ FileVault and Apache Maven.

9) As a next step, see Craig Dickson’s article on the CQ Blueprints Maven Repository, developed by headwire.com.

Source: http://cq-ops.tumblr.com/post/31404223822/how-to-use-apache-maven-to-build-and-deploy-osgi

1 comment:

  1. while taking content from CQ in JSP page, shows some script missing.("jquery191 undefined").Tried adding var jquery191=$.noConflict();.It worked, but "$ is not a function" error getting. Please suggest a solution how to get script included in html of cq page in jsp.

    ReplyDelete