Ir al contenido principal

Creating an AEM application using Maven and Adobe's archetype

In this tutorial, I show how to use Maven and Adobe's archetype to create an application from scratch and then build it and deploy it into AEM, also, the last part of the video shows how to do the same process using a Maven container using Docker, above is the vid and below you will find some useful notes.
  1. 1.


  2. 2.

    What is Maven

    • Maven is among many things a build automation tool which uses xml files called Project Object Model or POM files to describe different things about a project like what dependencies the project has, how to build and deploy a project and so on.
    • For dependency management, Maven uses two types of artifact repositories which can be categorized as:
    • Remote, which are typically publicly available on the internet like Maven Central or privately available inside your company’s internal network.
    • And local repositories, which are typically inside a .m2 folder inside your local file system where maven runs and it’s used for caching and storing local builds.
  3. 3.

    Maven Archetypes

    • Maven archetypes can be used for creating new applications or modules without going through the hassle of configuring each piece of the app by hand, like the appropriate libraries or the plugins required, the different profiles to execute and many other different things needed to provide a seamless development experience. In our case adobe’s archetype will take care of even creating some mock content, example classes, components, configurations and other stuff for us so that we can start tinkering with our new app right away.
      mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate "-DarchetypeGroupId=com.adobe.granite.archetypes" "-DarchetypeArtifactId=aem-project-archetype" "-DarchetypeVersion=19" "-DarchetypeCatalog=" "-DgroupId=co.dlighthouse.aem.firstapp" "-DartifactId=aem-first-app" "-Dversion=0.1.0-SNAPSHOT" "-Dpackage=co.dlighthouse.aem.firstapp" "-DappsFolderName=first-app" "-DconfFolderName=first-app" "-DartifactName=First App Example" "-DcomponentGroupName=First App Example" "-DcontentFolderName=first-app" "-DcssId=first-app" "-DpackageGroup=first-app" "-DsiteName=First App Example" “-DoptionAemVersion=6.4.0”
    • Adobe’s archetype will generate a multi module project, with modules for the bundle that contais all the java classes like Sling models and sling servlets, another module for creating the AEM package that contains the AEM components and a final one with the site and assets. There are two final modules used for testing.
  4. 4.

    Building and deploying

    • For building and deploying the application into an Author instance running locally using the 4502 port
      mvn clean install -PautoInstallPackage -Padobe-public
  5. 5.

    Docker and Maven

    • If you recall from the video, maven uses a local .m2 folder for the local repository and that whenever a dependency is missing there it will try to download it from the remote repository. When using Docker containers and given that they are isolated from each other if we just try to execute the maven commands it will try to download everything every time you use a new container.
    • To avoid that we need to use Docker Volumes which will allow us to define a local folder on your machine so that docker can use it for storing the artifacts downloaded by maven and so that they can be reused from different containers.
    • For defining a volume when starting a container you just need to add a -v parameter followed by a mapping, in which you specify the local folder in which the files are or should be located, a colon and the internal container’s folder
      docker run ... -v LOCAL-FOLDER:CONTAINER-FOLDER ...
    • If you want to check the current contents of a folder using the container you can use bash instead of the maven command at the end
      docker run -it --rm --name my-maven-project -v "$(pwd)":/usr/src/workdir -w /usr/src/workdir -v "$(pwd)"/.m2:/root/.m2 maven:3.6.1-jdk-8 /bin/bash
    • For creating the app you can use docker and append the complete maven command that uses the archetype after that
      docker run -it --rm --name my-maven-project -v "$(pwd)":/usr/src/workdir -w /usr/src/workdir -v "$(pwd)"/.m2:/root/.m2 maven:3.6.1-jdk-8 mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate "-DarchetypeGroupId=com.adobe.granite.archetypes" "-DarchetypeArtifactId=aem-project-archetype" "-DarchetypeVersion=19" "-DarchetypeCatalog=" "-DgroupId=co.dlighthouse.aem.firstappdocker" "-DartifactId=aem-first-app-docker" "-Dversion=0.1.0-SNAPSHOT" "-Dpackage=co.dlighthouse.aem.firstappdocker" "-DappsFolderName=first-app-docker" "-DconfFolderName=first-app-docker" "-DartifactName=First App Docker Example" "-DcomponentGroupName=First App Docker Example" "-DcontentFolderName=first-app-docker" "-DcssId=first-app-docker" "-DpackageGroup=first-app-docker" "-DsiteName=First App Docker Example" “-DoptionAemVersion=6.4.0”
    • You can acomplish the same thing here by appending just the build MAven command after the docker one
      docker run -it --rm --name my-maven-project -v "$(pwd)":/usr/src/workdir -w /usr/src/workdir -v "$(pwd)"/../.m2:/root/.m2 maven:3.6.1-jdk-8 mvn clean install -Padobe-public -PautoInstallPackage
  6. 6.


  1. We began enterprise as a machine tool producer in 1938 under the Shibaura name, and our Shibaura model, which we proceed to make use of, remains to be widely recognized around the globe, especially within the machine tool trade. Frozen Layer – During mildew filling, as molten plastic out there in} contact with the perimeter of any cooled channel a frozen layer will develop. An initial frozen pores and skin will develop nearly immediately and its thickness will dynamically change throughout the mildew filling and precision machining packing portions of the molding cycle. During mildew filling, the thickness is considerably influenced by shear rate and will influence the filling pressure. Our digital solutions assist you alongside the complete product life cycle.


Publicar un comentario

Entradas populares de este blog

How to copy files from and to a running Docker container

Sometimes you want to copy files to or from a container that doesn’t have a volume previously created, in this quick tips episode, you will learn how. Above is the vid and below you will find some useful notes. 1. Pre-reqs Have Docker installed 2. Start a Docker container For this video I will be using a Jenkins image as an example, so let’s first download it by using docker pull docker pull jenkins/jenkins:lts

How to create an AEM component using Reactjs

In this tutorial, I will show how to use use Adobe's archetype to create an AEM application with React.js support and also how to add a new React.js component so that it can be added into a page, above is the vid and below you will find some useful notes. In the second part we will see how to configure the Sling Model for the AEM React component. 1. Pre-reqs Have access to an Adobe Experience Manager instance. You will need aem 6.4 Service Pack 2 or newer. Have Maven installed, understand how it works and also understand how to use Adobe's archetype, you can watch my video about maven here: Creating an AEM application using Maven and Adobe's archetype 2.

House price prediction 3/4: What is One Hot Encoding

A series about creating a model using Python and Tensorflow and then importing the model and making predictions using Javascript in a Vue.js application, above is the vid and below you will find some useful notes. Here, in part 3 of this series, I will show what is and how does one hot encoding works. In the first post, called House price prediction 1/4: Using Keras/Tensorflow and python , I talked about how to create a model in python, pre-process a dataset I've already created, train a model, post-process, predict, and finally about creating different files for sharing some information about the data for use on the second part. Then in part 2, called House price prediction 2/4: Using Tensorflow.js, Vue.js and Javascript , I took the model, the data for pre and post processing and after loading everything we were finally able to predict