AEM Project Archetype
The AEM Project Archetype creates a minimal, best-practices-based Adobe Experience Manager project as a starting point for your own AEM projects. The properties that must be provided when using this archetype allow you to specify the names for all parts of this project as well as control certain optional features.
The archetype has a number features that are intended to offer a convenient starting point for new AEM projects:
- English and French pages with example content
- A content template based on the editable template feature with example content policy
- Configurations for device emulators, drag-and-drop setup, and internationalization
- Client libraries following BEM naming conventions as well as component-specific styles
- Example bundles including sample models, servelts, filters, and schedulers
- Unit, integration, and client-side tests
- Sample SPA implementations in React or Angular (optional)
Why Use the Archetype
Using the AEM Project Archetype sets you on the path towards building a best-practices-based AEM project with just a few keystrokes. By using the archetype, all of the pieces will already in place so that while the resulting project is minimal, it already implements all of the key features of AEM so that all you have to do is build on top and extend.
Of course there are many elements that go into a successful AEM project, but using the AEM Project Archetype is a sound foundation and is strongly recommended for any AEM project.
The project archetype makes it easy to get started developing on AEM. You can take your first steps in a number of ways.
- WKND Tutorial - For a great introduction to developing on AEM including how to leverage the archetype see the Getting Started with AEM Sites - WKND Tutorial for a practical example that walks you through using the archetype to implement a simple project.
What You Get Using the Archetype
The AEM Archetype is made up of modules:
- ui.launcher: contains glue code that deploys the ui.tests bundle (and dependent bundles) to the server and triggers the remote JUnit execution.
The modules of AEM Archetype represented in Maven are deployed to AEM as content packages representing the application, the content, and the necessary OSGi bundles.
The current version of the archetype has the following requirements:
For a list of supported AEM versions of previous archetype versions, see the historical supported AEM versions .
How to Use the Archetype
To use the archetype, you first need to create a project, which generates the modules in a local file structure as previously described . As part of project generation, a number of properties for your project can be defined such as project name, version, etc.
Building the project with Maven creates the artifacts (packages and OSGi bundles), that can be deployed to AEM. Additional Maven commands and profiles can be used to deploy the project artifacts to an AEM instance.
Creating a Project
To get started you can most simply use the AEM Eclipse extension and follow the New Project wizard and choosing
AEM Sample Multi-Module Projectto use a released version of the archetype.
Of course you can also invoke Maven directly.
mvn archetype:generate \ -DarchetypeGroupId=com.adobe.granite.archetypes \ -DarchetypeArtifactId=aem-project-archetype \ -DarchetypeVersion=XX
XXis the version number of the latest AEM Project Archetype.
It is best practice to add the
adobe-publicprofile to your Maven
settings.xmlfile in order to automatically add repo.adobe.com to the maven build process.
An example POM can be found here .
The following properties are available when creating a project using the archetype.
Base Maven ArtifactId
Java Source Package
Application ID used for component, configuration, and content folders and css IDs
Application title used for the website title and components groups
Target AEM version
Language and country code to create the localized content structure (e.g.
Include a Component Library example site
Include a custom 404 response page
Create language-master structure in example content
If the archetype is executed in interactive mode the first time, properties with default values can't be changed (see ARCHETYPE-308 for more details). The value can be changed when the property confirmation at the end is denied and the questionnaire gets repeated, or by passing the parameter in the command line (e.g.
The generated maven project supports different deployment profiles when running
Install core bundle with the maven-sling-plugin to the felix console
Install the ui.content and ui.apps content package with the content-package-maven-plugin to the package manager to default author instance on localhost, port 4502. Hostname and port can be changed with the
aem.portuser defined properties.
Install the ui.content and ui.apps content package with the content-package-maven-plugin to the package manager to default publish instance on localhost, port 4503. Hostname and port can be changed with the
aem.portuser defined properties.
allcontent package with the content-package-maven-plugin to the package manager to default author instance on localhost, port 4502. Hostname and port can be changed with the
aem.portuser defined properties.
allcontent package with the content-package-maven-plugin to the package manager to default publish instance on localhost, port 4503. Hostname and port can be changed with the
aem.portuser defined properties.
Runs the provided integration tests on the AEM instance (only for the
Building and Installing
To build all the modules run in the project root directory, use the following Maven command.
mvn clean install
If you have a running AEM instance, you can build and package the whole project and deploy into AEM with the following Maven command.
mvn clean install -PautoInstallPackage
To deploy it to a publish instance, run this command.
mvn clean install -PautoInstallPackagePublish
Alternatively, to deploy to a publish instance, run this command.
mvn clean install -PautoInstallPackage -Daem.port=4503
Or to deploy only the bundle to the author, run this command.
mvn clean install -PautoInstallBundle
pom.xmlat the root of the project (
<src-directory>/<project>/pom.xml) is known as the parent POM and drives the structure of the project as well as manages dependencies and certain global properties of the project.
Global Project Properties
<properties>section of the parent POM defines several global properties that are important to the deployment of your project on an AEM instance such as user name/password, host name/port, etc.
These properties are set up to deploy to a local AEM instance, as this is the most common build that developers will do. Notice there are properties to deploy to an author instance as well as a publish instance. This is also where the credentials are set to authenticate with the AEM instance. The default admin:admin credentials are used.
These properties are set up so that they can be overridden when deploying to higher level environments. In this way the POM files do not have to change, but variables like
sling.passwordcan be overridden via command line arguments:
mvn -PautoInstallPackage clean install -Daem.host=production.hostname -Dsling.password=productionpasswd
<modules>section of the parent POM defines the modules that the project will build. By default the project builds the standard modules previously defined : core, ui.apps, ui.content, ui.tests, and it.launcher. More modules can always be added as a project evolves.
<dependencyManagement>section of the parent POM defines all of the dependencies and versions of APIs that are used in the project. Versions should be managed in the Parent POM. Sub-modules like core and ui.apps should not include any version information.
One of the key dependencies is the AEM uber-jar . This will include all of the AEM APIs with just a single dependency entry for the version of AEM.
As a best practice you should update the uber-jar version to match the target version of AEM. For example, if you plan to deploy to AEM 6.4 you should update the version of the uber-jar to 6.4.0.
The AEM Project Archetype of course leverages the Core Components.
The Core Components are installed in AEM automatically in the default runmode and used by the sample We.Retail site. In a production runmode (
nosamplecontent) the Core Components are not available.
Therefore, in order to leverage the Core Components in all deployments, it is a best practice to include them as part of the Maven project.
Each release of the Core Components is generally followed by a release of the AEM Project Archetype so that the latest archetype uses the latest version of the core components.
However a new version of the archetype may not directly follow a new version of the Core Components, so you may wish to update the dependency on the Core Components to the latest version.
The core.wcm.components.examples are a set of sample pages that illustrate examples of the Core Components. As a best practice, when deploying a project for production use you should remove this dependency and subpackage inclusion.
There are three levels of testing contained in the project and because they are different types of tests, they are executed in different ways or in different places.
- Unit test in core: This showcases classic unit testing of the code contained in the bundle. To test, execute:
- mvn clean test
- Server-side integration tests: These run unit-like tests in the AEM-environment, i.e. on the AEM server. To test, execute:
- mvn clean verify -PintegrationTests
- Load AEM in your browser as you would to author a page.
- Open the left panel and switch to theTeststab.
- Find the generatedMyName Testsand run them.
So you have built and installed the AEM Project Archetype. What now? Well, the archetype is small, but consists of many examples of powerful AEM features configured according to recommended best practices. Use these are indicatory of how you can leverage these features in your project. For any project you likely need to: