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

Introduction

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 Maven

Install Apache Maven following the official installation instructions. Verify the installation:

1
mvn --version

Step 2: Configure Maven Settings

Configure Maven settings in the settings.xml file (located in your .m2 directory). Add 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 HTTPS connections.

Step 3: Generate the Project

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: Configure the POM

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

Build and deploy the project using Maven profiles:

  • From the root directory: mvn -PautoInstallPackage clean install - builds and installs the full package to the author instance
  • From the bundle directory: mvn -PautoInstallBundle clean install - builds and installs only the OSGi bundle

Next Steps

With the project structure in place, you can begin developing components, templates, and OSGi services. Consider exploring the AEM Project Archetype for more recent project setups that support AEM 6.3 and above.

Contents