Part 1: Lazybones Generator for AEM

1. Introduction

This is first part of multi-part series where we'll talk about how Lazybones is useful in AEM projects.

Starting new project from scratch/base is an exciting task and we want to give our best whenever we are starting something new. We try to pour all our past experiences and learnings together to make sure that we are not doing same mistakes that we have done or found in other projects.

Developing large projects goes through various phases:

1) Requirement gathering and analysis
2) Create high level and low level architecture and technical design
3) Choosing frameworks/libraries for development
4) Choosing unit testing frameworks
5) Hooking up build scripts
6) Choosing dependency management tool
7) Defining DevOps strategy
8) Infrastructure – Cloud or In House
9) And many more….

Individual people might have worked on different projects and each of them might have faced different problems and might have learned many best practices. It’s quite possible that when you are starting new project either you don’t know best practices that other individuals might have learned (and you’ll not get benefit from their learning) or you are working on completely new technology and have no idea where and how to start. How about a tool which will allows you to create a ready to go boilerplate project with all best practices?

In this article, we are going learn about one such tool (i.e. Lazybones) and will use to simplify challenges that we have with integrating AEM and Angular 5 together. Lazybones can do much more but, in this article our focus will be on #3, 4, 5 and 6. Lazybones can be extended to handle other AEM related challenges, this is just a sample use case that we have picked for illustrating benefits of using Lazybones with AEM.

2. AEM with Angular 5 project challenges

Adobe Experience Manager (AEM), is a content management platform for building websites, mobile apps and forms - making it easy to manage your marketing content and assets. AEM empowers business users and non-technical staff to create and manage content as per business needs.

Angular 5 is modular in nature, what that means is there are number of smaller modules that you can choose to mix and match based on what is required in your project. When you are developing Angular 5 application outside of AEM this is not a big challenge in terms of building and shipping an Angular 5 application out of the door because there are many build tools (e.g. Angular 5 CLI) are available to take care of managing these smaller angular modules and dependencies. But, when we are in AEM, components are just building blocks and content authors can drag-drop these components anywhere and as many times as they need so, reusability is key i.e. authors should be able to use Angular 5 components in same way as regular AEM component. So, this mean build tools that are available today for Angular 5 application can’t help because those tools need to know upfront where components have been used and then these tools compiles applications but, in AEM this is different (as we discussed above).

To address this problem, we need to write complex build script, hooks up right dependencies (both for AEM and Angular) and integrate unit testing libraries.

Follow these links to read more about challenges in details: http://suryakand-shinde.blogspot.com/2017/06/part-1-angular-2-with-aem-introduction.html

3. Lazybones

3.1. What is Lazybones

Definition from Lazybones repository page:
It allows you to create a new project structure for any framework or library for which the tool has a template. You can even contribute templates by sending pull requests to this GitHub project or publishing the packages to the relevant Bintray repository.
The concept of Lazybones is very similar to Maven archetypes, and what Yeoman does for web applications. Lazybones also includes a sub-templates feature that resembles the behavior of Yeoman's sub-generators, allowing you to generate optional extras (controllers, scaffolding etc.) inside a project.

3.2. Why Lazybones

Often when we are working on a project we spend a lot of time to create project foundation, folders, base skeleton of project, hookup build scripts, add right dependencies and other DevOps related tools/configurations and this takes a lot of time. If you look for solutions, you will quickly find that people have solved this problem using tools like:

If you are working on projects that have different needs from build, code organization and packaging perspective you’ll realize that standard maven archetypes available publically will not suffice your needs. This is where Lazybones capabilities will help. In next few sections we learn:
  • Installing Lazybones
  • What is Lazybones
  • How to create a Lazybones projects template to generate an AEM + Angular 5 project
  • How to use template
  • Use cases for Lazybones
  • Best practices

3.3. Installing Lazybones

The easiest way install Lazybones is with sdkman.
Step 1:  Installation and validation of sdkman
  • Open terminal and type command curl -s "https://get.sdkman.io" | bash
  • Quit and reopen terminal
  • Validate installation by typing command sdk version in terminal


Fig: Eclipse Gradle project import modal

Step 2:  Installation and validation of lazybones

  • Open terminal and type command sdk install lazybones

For more information about installation, please visit https://github.com/pledbrook/lazybones

4. Lazybones Use Cases and Advantages

We saw project setup challenges, available options and learned about Lazybones templates. In this section, we’ll see where should we use it and what are advantages of using it?

4.1. Use Cases

  • Project is composed of various technologies and frameworks
  • Project is complex to hand craft and it takes a lot of time to setup new project
  • Project that have large set of configuration that are difficult to remember while creating project
  • Projects that need same project structure, configurations and setup to be repeated multiple times
  • Project in which traditional scaffolding mechanisms of setting up project (e.g. Maven archetype) are insufficient
  • Project which needs customized build script which is difficult to hand craft every time

4.2. Advantages

  • Less time to setup new project
  • No need to worry about complex configurations, build process etc.
  • Standardized way of creating project and other artifacts (components, templates, services etc.) using best practices that are baked into Lazybones templates. 
  • Individual developers don’t need to worry about complexities and don’t need to spend time writing boilerplate code


Comments

Popular posts from this blog

AEM, FORM Submission & Handling POST requests

AEM - Query list of components and templates

AEM 6.3 - Bundle Whitelisting - Deprecation of administrative authentication

AEM as a Cloud Service (AEMaaCS) – Architecture Overview