/aem-project

aem maven projects and components

Primary LanguageJavaScript

aem-project

Branches

As of 2024, develop branch will be used for new work going forward. Tags create from develop are being used for blog post source code links. For example, hellomultifield

After develop branch code has been completed and validated, it will get merged into master.

These old branches are still linked to jimfrenette.com AEM posts.

Resources

Archetype 43

Step 1, backup previous archetype project. For example,

cd src

mv myproject myproject24

Step 2, create new archetype-project. For example

mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate \
 -D archetypeGroupId=com.adobe.aem \
 -D archetypeArtifactId=aem-project-archetype \
 -D archetypeVersion=43 \
 -D aemVersion=6.5.0 \
 -D appTitle="My Project" \
 -D appId="myproject" \
 -D groupId="com.myproject" \
 -D language=en \
 -D country=us \
 -D singleCountry=n \
 -D frontendModule=general

Archetype 24

Archetype 23

Archetype 22

Docker Dispatcher

Given that appId="myproject" was used when creating the archetype project.

Build the docker image

cd src/myproject

docker build \
    -t myproject/dispatcher:latest \
    --build-arg MODULE_URL=https://download.macromedia.com/dispatcher/download/dispatcher-apache2.4-linux-x86_64-4.3.3.tar.gz \
    .

If connection to registry-1.docker.io fails "unauthorized: incorrect username or password", use

docker logout

and retry the build

If you need to setup a publish instance ...

create publish folder and rename the aem distro quickstart jar

mkdir publish
cd publish

java -jar cq5-publish-p4503.jar -unpack

update the crx-quickstart/bin/start script to use the publish port, e.g.,

# TCP port used for stop and status scripts
if [ -z "$CQ_PORT" ]; then
    CQ_PORT=4503
fi
# runmode(s)
# will not be used if repository is already present
if [ -z "$CQ_RUNMODE" ]; then
    CQ_RUNMODE='publish'
fi

After starting the publish instance, if needed, build and deploy myproject to publish instance running on port 4503

mvn -PautoInstallPackage -Daem.port=4503 clean install

validate myproject running on publish http://localhost:4503/content/myproject/us/en.html

update your hosts file to map 127.0.0.1 to the entries in docker-compose.yml

# AEM myproject dispatcher
127.0.0.1	author.mycompany.local
127.0.0.1	myproject.mycompany.local

Start the container

docker-compose up -d

validate myproject running on dispatcher: http://myproject.mycompany.local/content/myproject/us/en.html

For more info, https://blogs.perficient.com/2021/01/05/setting-up-a-local-aem-dispatcher-with-docker/

WSL2 Environment

Running AEM on the Windows file system while building and deploying code from WSL2 Linux.

  • Add this resolv.sh script to your WSL2 Linux.

  • Run resolv anywhere given $HOME/bin is in your environment PATH. Place resolv.sh in the /bin directory and make it executable. e.g., chmod +x resolv.sh. Rename it resolv, e.g., mv resolv.sh resolv.

For example

> $ resolv                                                                                            ⬡ 14.18.1 [±archetype-43 ✓]
Enter hostname to add or update, e.g., win.localhost
HOSTNAME: win.localhost
192.168.96.1
win.localhost was not found in your /etc/hosts
Adding win.localhost to your /etc/hosts
[sudo] password for <user>:
win.localhost was added succesfully:
192.168.96.1 win.localhost
  • Run AEM using Powershell
cd author\crx-quickstart\bin
> ./start.bat
  • Maven build with win.localhost in our Linux etc/hosts file added / updated by the resolv script.
mvn -PautoInstallSinglePackage -Daem.host=win.localhost clean install
server=http://win.localhost:4502
credentials=admin:admin