April 16, 2020
Estimated Post Reading Time ~

Configure Maven with Eclipse in AEM

The focus of this tutorial is to provide step by step examples and explanations to configure Maven , git , java with eclipse in AEM. This tutorial is for AEM beginners for setting up AEM workspace.

Topics covered in this tutorials:
Steps for installing and configuring Maven in Windows.
Steps for configuring Maven Plugin (m2e) in Ecllipse.
Steps for configuring Git in Windows.
Building Maven Project in Eclipse.
Trouble-shooting Maven Build Errors.
Steps for installing and configuring Maven in Windows

Download binary version of Maven from Maven Official Site.
Right click and extract the files into folder.

Set the Environment Variable Paths.
Add M2_HOME and MAVEN_HOME.
Note:- Apache Maven document suggest that only M2_HOME is sufficient but some software’s require MAVEN_HOME also.

Add maven bin folder location to path system variable.

Verify Maven configuration.

Steps for configuring Maven Plugin (m2e) in Ecllipse

Download eclipse and unzip it.
Start Eclipse, set your workspace to something suitable (e.g. C:\Project\workspace).

Install Maven plugins(After eclipse Kepler version eclipse provide out of the box m2e plugin). Go to Help > Install New Software.

Select ‘All Available Sites‘ in the Work with field. Use the search field labelled as ‘type filter text‘ to find and select maven plugins :
m2e – Maven Integration for Eclipse.

Note:- If by entering m2e in search bar no result is displayed. It means repository is missing with our ecllipse installation. Follow below steps to resolve the issue:


Enter following url in work with field to get plugin via main update. http://download.eclipse.org/technology/m2e/releases

Collaboration > m2e – Maven Integration for Eclipse
Click Next to continue.
Click ‘Next’ again and accept the terms and conditions for usage of the plugins.

Proceed by clicking Finish accepting any unsigned content warning messages that appear.

An install progress bar will appear and download the plugins. Once complete a message will appear asking if you would like to restart eclipse. Click No.


Steps for configuring Git in Windows
Download Git.
Double click the exe file and install Git.
Add Git cmd folder location to path system variable.


Building Maven Project in Eclipse
Download your AEM project code from any version control like GitHub or SVN into your local system.
Open eclipse –> Right click and select import.
Select Existing Maven Project from list. Click Next


Browse Root folder of AEM project that you have downloaded from GitHub or SVN.

Click Finish.
Open command prompt –> Go to the project root folder (C://users/<username>/git/<project-name>).
Run mvn clean install -p <AEM/CQ instance name>.

Trouble Shooting Maven Build Errors
If you face any caching issue delete the target folder from project.
While building Maven project you might get “Failed to execute goal org.apache.maven.plugins“.

Note: Root cause of this error is during the installation of Maven any plugin was not installed properly.

Try deleting .m2 directory from (C://users/<username>/.m2) and re-run mvn command.
Try moving to lower Maven version, might be few properties are not supported in maven latest version by your project.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.