Create Adobe AEM Project from Scratch in 5 Steps with Apache Maven

Evgeniy Fitsner Software Engineer
3 min read
Create Adobe AEM Project from Scratch in 5 Steps with Apache Maven

Every AEM project beyond basic examples should contain server-side business logic, environment-specific configurations, page templates, component templates, and tests — organized into small, maintainable modules with Java classes and content kept separate. Apache Maven provides an ideal solution for managing this structure.

Step 1

Install Apache Maven following the official installation instructions.

Step 2

Configure Maven settings in the settings.xml file. Add repository and plugin repository configurations to enable Maven to locate AEM artifacts:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<repositories>
    <repository>
        <id>adobe-public-releases</id>
        <name>Adobe Public Repository</name>
        <url>https://repo.adobe.com/nexus/content/groups/public/</url>
        <layout>default</layout>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>adobe-public-releases</id>
        <name>Adobe Public Repository</name>
        <url>https://repo.adobe.com/nexus/content/groups/public/</url>
        <layout>default</layout>
    </pluginRepository>
</pluginRepositories>

Note: Adobe repositories require secured HTTP.

Step 3

Create a folder for the new project and navigate to it in the terminal. Generate the project using the multimodule-content-package-archetype:

1
2
3
4
5
6
7
8
9
10
11
12
13
mvn archetype:generate \
-DarchetypeGroupId=com.day.jcr.vault \
-DarchetypeArtifactId=multimodule-content-package-archetype \
-DarchetypeVersion=1.0.2 \
-DarchetypeRepository=adobe-public-releases \
-DgroupId=com.drfits.aem.meetup \
-DartifactId=sling-healthchecks \
-Dversion=1.0.0-SNAPSHOT \
-Dpackage=com.drfits.aem.meetup.healthchecks \
-DappsFolderName=healthchecks \
-DartifactName="Health Checks: AEM 6.2" \
-DcqVersion="6.2.0" \
-DpackageGroup="AEM Meetup Health Checks"

Step 4

After generation, configure the main pom.xml. Add the UberJar dependency:

1
2
3
4
5
6
7
<dependency>
    <groupId>com.adobe.aem</groupId>
    <artifactId>uber-jar</artifactId>
    <version>6.2.0</version>
    <classifier>apis</classifier>
    <scope>provided</scope>
</dependency>

Add deployment properties:

1
2
3
4
5
6
7
8
9
10
11
12
<properties>
  <crx.host>localhost</crx.host>
  <crx.port>4502</crx.port>
  <crx.username>admin</crx.username>
  <crx.password>admin</crx.password>
  <publish.crx.host>localhost</publish.crx.host>
  <publish.crx.port>4503</publish.crx.port>
  <publish.crx.username>admin</publish.crx.username>
  <publish.crx.password>admin</publish.crx.password>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

Step 5

Build and deploy the bundle:

  • From the root directory: mvn -PautoInstallPackage clean install — builds and installs to a CQ instance
  • From the bundle directory: mvn -PautoInstallBundle clean install — builds and installs only the bundle

The five-step process establishes an AEM project structure ready for development.