Create AEM Project Structure using Lazybones

Adobe is recommending its customers to create AEM project structure using Lazybones instead of traditional Maven archetype 10. As when we create a aem project using Maven archetype it is not easy to customize, it provides lots of sample content and packages like test, launcher. Which might not be required for your project, on contrary lazybones bones is very interactive , flexible and easy to customize according to your project need. Adobe consulting Services (ACS) provides a aem multi module template using which you can create AEM projects, which includes lot of default config options and also provides an option to include the ACS commons package as a sub package.

The aim of this tutorial is to learn what is lazybones and how we can use it to create an aem skeleton project structure, as Adobe consulting Services (ACS) has updated the template version and provided the support for AEM 6.3 also i am going to create project structure for AEM 6.3, for learning i am using windows machine so we are going to install lazybones on windows, but you can install it on linux and other operating systems also.

Lazybones Overview:-

Lazybones is a command line tool and is build in two parts. First lazybones command line tool and second project templates. This command line tool allows you to create a new project structure for any framework or library for which the tool has a template. Currently ACS has contributed one template for creating AEM multi module project, which we are going to use in this tutorial.

You can also contribute templates by sending pull requests to this GitHub project or publishing the packages to the relevant Bintray repository.

Install Lazybones:-

In order to install Lazybones for creating skeleton project structure in aem follow below steps:-

  • Go to link https://bintray.com/pledbrook/lazybones-templates/lazybones#files and the latest lazybones.zip file. currently it is lazybones-0.8.3.zip.
    download-lazybones
  • Extract the zip file and set the environment path variable to \lazybones-0.8.3\bin
  • Open command prompt and type lazybones. If lazybones is successfully installed then you will see list of available commands as shown below.
    check_lazybone_installation

Note:- If you get error like lazybones is not a command, then check environment path is configured correctly or download the package again as it might be corrupted.

Create Project Structure using Lazybones.

Command to create new project using lazybones-

lazybones create <template name> <template version> <target directory>

Note:- Here template version is optional and if you leave it out, Lazybones will install the latest version of the template it can find

Follow below steps to create aem project structure using lazybones:-

  • Open command prompt.
  • Run below command
lazybones create aem-multimodule-project aemtraining
  • Press Enter, it will ask you series of questions. Enter the updated value, if you feel that you dont want default value else just keep pressing enter for default values.

create-aem-lazybones-project-structure

Note:- Here create is the lazybone command, aem-multimodule-project is acs common template name for creating the project and aemtraining is the folder/directory name where i want to create my project. If aemtraining folder is not available then it creates this folder.

 

DescriptionDefaultParameter Name
Maven Group IDcom.mycogroupId
Maven Artifact IDexample-projectartifactId
Use New Module Naming Convention (core, ui.apps)yesuseNewNamingConvention
Put Bundle in “bundles” sub-directorynobundleInBundlesDirectory
Bundle Artifact IDexample-project-bundle/example-project.corebundleArtifactId
Content Package Artifact IDexample-project-content/example-project.ui.appscontentArtifactId
Maven Version0.0.1-SNAPSHOTversion
Project NameMy AEM ProjectprojectName
Group name for Content Packagemy-packagespackageGroup
Target AEM Version6.2aemVersion
Folder to create under /appsmy-aem-projectappsFolderName
Folder to use under /contentmy-aem-projectcontentFolderName
Create AEM 6.2 Editable Templates folders?yescreateEditableTemplatesStructure
Folder to create under /confmy-aem-projectconfFolderName
Create a site design?yescreateDesign
Design folder namemy-aem-projectdesignFolderName
Create a main client library?yescreateMainClientLib
Create a dependencies client libraryyescreateDependenciesClientLib
Enable code quality checks?yesenableCodeQuality
Create Environment-Specific Config Folders?yescreateRunModeConfigFolders
Environment Nameslocaldev,dev,qa,stage,prodenvNames
Create Author and Publish Config Folders per Environment?yescreateAuthorAndPublishPerEnv
Set root mapping to /welcome (Classic UI)?yes in 5.6.1, no in 6.0reconfigureRootMapping
Set Default Authoring UI to Classic? (6.0 only)yesenableClassicAuthoringAsDefault
Include ACS AEM Commons?yesincludeAcsAemCommons
Include ACS AEM Commons as a sub-package?yesincludeAcsAemCommonsSubPackage
Enable ACS AEM Commons Error Handler?yesenableErrorHandler
Default Error Page Path/content/my-aem-project/errors/404defaultErrorPath
Define Error Page Folder for /content/my-aem-project ?nodefineErrorPageFolder
Error Page Folder for /content/my-aem-projecterrorserrorFolder
Enable ACS AEM Commons Pages Reference Provider?yesenablePagesReferenceProvider
Enable ACS AEM Commons Design Reference Provider?yesenableDesignReferenceProvider
Enable ACS AEM Commons Design Html Library Manager?yesenableDhlm
Enable ACS AEM Commons Versioned Client Libraries?yesenableVersionedClientLibs
Using Sling Models?yesusingSlingModels
Sling Models PackageslingModelsPackage
Purge DAM Workflows?yespurgeDamWorkflows
DAM Workflow Retention Period (days)7purgeDamWorkflowRetention

Import Generated AEM Project using lazybones to Eclipse:-


Now as we have created our skeleton project structure using lazybones for aem 6.3, we need to import it to our IDE for editing the files. Follow below steps to import maven project to eclipse:-

  • Open eclipse.
  • Open the File menu and select Import. In the Import type, select Existing Maven Projects (inside the
    Maven folder).
    import existing maven project into workspace
  • Click Next and Click the Browse button and select your project directory/folder, that you have given at time of generating the project.
    import_maven_project_aem
  • Click Finish. You should be able to see below three projects has been added to your eclipse explorer.

aem_skeleton_project_structure

Each for these project serve different purpose:-

  • aem-training – This project acts as the container for the two other projects. We should not use this project directly.
  • aem-training.core – This project contains Java code which will be deployed to AEM as an OSGi bundle.
  • aem-training.ui.apps – This project contains configuration, server-side scripts, client-side scripts, and styling code (CSS). Developers used to spend bulk of their time in this project.

 

Spread the love

Leave a Reply to Ankur Ahlawat Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.