Adobe Experience Manager (AEM) Maven Project

An Adobe Experience Manager (AEM) example to demonstrate creating and deploying a Maven Multi Module project using an aem-project-archetype. This tutorial was created for deployment using Java 11, Apache Maven 3.6.2, Maven AEM Project Archetype 22 and AEM version 6.5.

Requirements

More information

Optionally activate the adobe-public profile by default in user Maven settings. The settings.xml for Maven is usually located in the hidden .m2 user directory.

settings.xml
<profile>
    <id>adobe-public</id>

    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>

    ...
</profile>    

Project

In a terminal, in your projects directory, create a directory for the source code. e.g.,

cd myproject

mkdir src

In the source code directory, use mvn to init the project with the desired archetype version. e.g.,

mvn archetype:generate \
 -Padobe-public \
 -DarchetypeGroupId=com.adobe.granite.archetypes \
 -DarchetypeArtifactId=aem-project-archetype \
 -DarchetypeVersion=22

Answer the prompts to setup the project. for example,

Property Value
groupId com.adobe.aem.dev
appsFolderName myproject
artifactId aem-dev-myproject
version 0.0.1-SNAPSHOT
package com.adobe.aem.dev.myproject
artifactName myproject
componentGroupName myproject
confFolderName myproject
contentFolderName myproject
cssId myproject
packageGroup myproject
siteName myproject

The Adobe WKND Tutorial Chater, Project Setup contains more information including other examples on how to set up the archtype property values.

Project structure generated by the Maven archetype

    00
  • src
    • aem-dev-myproject
      • core
      • it.launcher
      • it.tests
      • pom.xml
      • README.md
      • ui.apps
      • ui.content
      • .gitignore

Deploy to AEM

Provided your AEM author instance is running at localhost:4502, navigate to the source project directory created with the artifactId name. e.g.,

cd aem-dev-myproject

mvn -PautoInstallPackage clean install

If you get repository file read errors, locate the first one and note the file path. e.g.,

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] error reading /home/gilfoyle/.m2/repository/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar; zip END header not found

Delete the conflicting files from the repository. In this example, we’re deleting the 1.8.3 folder and its files under commons-beanutils

rm -rf /home/gilfoyle/.m2/repository/commons-beanutils/commons-beanutils/1.8.3

Run the mvn command again, this time with the update option. e.g.,

mvn -U -PautoInstallPackage clean install

The -U option will update the repository.

If everything works as expected, you should get output similar to the following:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for aem-dev-myproject 0.0.1-SNAPSHOT:
[INFO] 
[INFO] aem-dev-myproject .................................. SUCCESS [  0.247 s]
[INFO] myproject - Core ................................... SUCCESS [ 26.211 s]
[INFO] myproject - UI apps ................................ SUCCESS [  9.863 s]
[INFO] myproject - UI content ............................. SUCCESS [  4.639 s]
[INFO] myproject - Integration Tests Bundles .............. SUCCESS [  1.639 s]
[INFO] myproject - Integration Tests Launcher ............. SUCCESS [ 44.352 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:27 min
[INFO] Finished at: 2019-10-20T13:44:57-04:00
[INFO] ------------------------------------------------------------------------

Verify the package deployment and installation. For example, open the package manager at localhost:4502/crx/packmgr. Filter as needed, for example, select myproject under Groups. You should see both, aem-dev-myproject.ui.content and aem-dev-myproject.ui.apps packages version 0.0.1-SNAPSHOT installed.

AEM CRX Package Manager

Additional Reading

comments powered by Disqus