Search This Blog

Saturday 13 August 2016

AEM Install : Setting up author and publish instance AEM


At the infrastructure level AEM provides the following:

  • Web Application Server: AEM can be deployed in standalone mode (it includes an intergated Jetty web server) or as a web application within a third-party application server (WebLogic, WebSphere, etc).
  • Web Application Framework: AEM incorporates the Sling Web Application Framework that simplifies the writing of RESTful, content-oriented web applications.
  • Content Repository: AEM includes a Java Content Repository (JCR), a type of hierarchical database designed specifically for unstructured and semi-structured data. The repository stores not only the user-facing content but also all code, templates and internal data used by the application. 


The AEM software package is available in two forms:

  • cq-quickstart-6.1.0.jar: A standalone executable jar file that includes everything needed to get up and running.
  • cq-quickstart-6.1.0.war: A war file for deployment in a third-party application server.

    In addition you will also need a license code (to be entered on start-up) or 
    a license.properties file, holding a valid code.


Setting up author and publish instance AEM

Installing an Author Instance


This procedure describes how to set up a default Author instance on port 4502 of the desired host.

To install an author instance:
1.     On the host file system, create a directory and name it author.
2.    Copy the CQ5 cq-wcm-quickstart-<version>.jar file into author/.

3.    Rename cq-wcm-quickstart-<version>.jar to aem65-author-p4502.jar. If you need a different port this can be set in the filename.

4.    Copy a valid license.properties file into author/ as well (the same directory as the aem65-author-p4502.jar file).

5.    Start CQ WCM Quickstart:
       java -jar aem65-author-p4502.jar
 
            Additional cmds:
 
a.     For a 32-bit Java VM enter the following:

       java -Xmx1024M -jar aem65-author-p4502.jar

b.     For a 64-bit VM, enter:

       java -jar aem65-author-p4502.jar -XX:MaxPermSize=256m -Xmx1024M


Similarly, for publish- just use port 4503.


Running aem in debug mode





Development environment setup on local (for AEM)


Java Setup

Windows



Like the highlighted portion is downloaded for windows 64bit.





Setting up environment variable for java–

Environment variables- Windows-Help.txt

MAC


Download the .dmg file. Install it.

Set java home variable in bash_profile.
cd ~/
vi .bash_profile

add this line
export JAVA_HOME=$(/usr/libexec/java_home)



Maven Setup

Windows


Download latest maven, 3.3.9 in this case.


Download the zip file(highlighted). Unzip it.

Preferably store maven under program files only as environment variables need to be set for maven.




Setting up environment variable for maven–

Mac

            Built in maven. No need to configure env variables
            Further reading




Maven Central/Adobe repo

All jars are hosted in maven central over the internet. During build maven looks at the dependencies in pom.xml and downloads all jars from the repo.

Basically we can define 2 repos using profiles.

1.     Repository – place from where the dependencies will be downloaded.
You can define the public repo from where the maven downloads dependencies to m2 repo either in the project pom.xml or in the settings.xml.

a.     In Pom.xml – if a project is created using maven archetype the profiles are already present in the pom.xml. It defines the public repo used specific to the project.

b.     In settings.xml – need to explicitly define the repo. It defines the repo globally on the system. That is all projects can use the public repo defined in the settings.xml.

2.     Plugin Repo – place from where maven plugins will be download.


Profile code is mentioned in the below link. Just copy the profile code if required and copy to your setting.xml.


Configuring M2 repository in Maven settings.xml

M2 repo is the place where maven will put the dependencies once they are downloaded from adobe repository or maven central repo on the internet.

Recommended/default behavior - If you don’t configure local repo path in settings.xml then maven automatically creates m2 repo below users. For ex for me it got created below C:\Users\rahaggar\.m2 by default.

In MAVEN you can change the local repository path in the settings.xml in conf folder in maven.

example:
<localRepository>D:/rahul/EFES/DevPackage/maven-repository</localRepository>

Note: - Also put setting.xml file below .m2 folder alongside repository folder. Eclipse by default pics setting.xml file from this path.




Setup Eclipse IDE

Eclipse and Useful plugins for AEM developers




Importing maven project into eclipse


Open eclipse and
File->import->maven->existing maven project.
It may ask for some install on clicking next install that.






check all the pom.xml and import the project. 


Configuring maven with eclipse

Step1 : Select the path of settings.xml in User settings in eclipse


This is required so that eclipse knows from where to pick the jar files(location of m2 repo) to resolve errors. Eclipse by default pics setting.xml file from below .m2 .


GOTO windows-> preferences-> maven->user setting
then browse to the settings.xml and select it




Step 2  : Update project to resolve errors


update project by right clicking on the project triggers eclipse to pick up dependencies from m2 to resolve errors like “cannot resolve …”



AEM Setup





Deploying Code to aem

Maven is responsible for deploying the code from filesystem to m2 repo and finally to AEM
Build profiles can be created in pom which can be used for building and deploying projects using maven.
Some profiles are available by default as part of project created by maven archetype.

Build the code


Below command will Validate, compile, test and package the code but will not deploy to the author/publisher.

cd C:\Users\rahaggar\DevTools\UNHCR\GitCode\AEM-P15200\unhcr
mvn clean install -Dmaven.test.skip=true

Build and deploy to author


cd C:\Users\rahaggar\DevTools\UNHCR\GitCode\AEM-P15200\unhcr\ui.apps
mvn clean install -Dmaven.test.skip=true -PautoInstallPackage

Build and deploy to publish

mvn clean install -Dmaven.test.skip=true -PautoInstallPackagePublish