Setting up AEM project - bartoszWesolowski/aem-tips GitHub Wiki
Project setup
Prerequisites
- Maven installed
- Java installed
- Adobe public profile added to local maven settings - see Adobe documentation on setting up project locally.
AEM Project Archetype
One of the ways to set up AEM project is to use maven AEM Project Archetype (recommended by Adobe).
Creating a new project can be done with command like (check out plugin documentation to learn about all options that can be customized):
mvn -B archetype:generate \
-D archetypeGroupId=com.adobe.granite.archetypes \
-D archetypeArtifactId=aem-project-archetype \
-D archetypeVersion=23 \
-D aemVersion=6.4.0\
-D appTitle="My Site" \
-D appId="mysite" \
-D groupId="com.mysite" \
-D frontendModule=general \
-D includeExamples=n
This will generate a project structure similar to this:
|--- aem-guides-wknd/
|--- all/
|--- core/
|--- ui.apps/
|--- ui.content/
|--- ui.frontend /
|--- it.launcher/
|--- it.tests/
|--- pom.xml
|--- README.md
|--- .gitignore
core
- Java bundle containing all core functionality like OSGi services, listeners or schedulers, as well as component-related Java code such as servlets or request filters. On build code stored here will be assembled into a bundle and copied to ui.appsui.apps
- contains the/apps
parts of the project, ie JS&CSS clientlibs, components, and OSGi configsui.content
- contains structural content and configurations like editable templates, metadata schemas (/content, /conf)ui.tests
- Java bundle containing JUnit tests that are executed server-side. This bundle is not to be deployed onto production.ui.launcher
- contains glue code that deploys the ui.tests bundle (and dependent bundles) to the server and triggers the remote JUnit executionui.frontend
- (optional) contains the artifacts required to use the Webpack-based front-end build module. Build will process files here and generate a clientlibs that will be copied toui.apps
all
- this is an empty Maven module that combines the above modules into a single package that can be deployed to an AEM environment.
Diagram explaining the project structure:
Building the project
To build project run mvn clean install
in the root directory. To deploy the app to AEM instance (local by default) use on of the following profiles:
Profiles:
autoInstallBundle
- Install core bundle with the maven-sling-plugin to the felix consoleautoInstallPackage
- 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.host and aem.port user defined properties.autoInstallPackagePublish
Install the ui.content and ui.apps installed to publishautoInstallSinglePackage
- Install the all content package with the content-package-maven-plugin to the package manager to default author instance on localhost, port 4502.autoInstallSinglePackagePublish
- Install the all content package to publishintegrationTests
- Runs the provided integration tests on the AEM instance (only for the verify phase)
Fronted module
The ui.frontend
module is created to accelerate front end development. As AEM client libraries have limited support to new FE technologies this module includes a bridge between chosen FE technology and AEM clientlibs. On the build phase module will transform css/sass/js/ts files into a client lib and create a clientlib under ui.apps
- this clientlib will be deployed to AEM.
Transition between webpack module and client lib is possible because of AEM clientlib generator.