Search This Blog

Saturday 13 August 2016

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


No comments:

Post a Comment