Thursday, March 23, 2017

Create Multiple Bundles in an AEM Maven Project

Hi,

In AEM, Maven provides multi-module architecture.

What does it mean??
It means that we can have different modules like bundle and content(core,ui.apps) in a single project.

In this blog, we will discuss that how can we create multiple bundles in the same project.
Initially, when we create an AEM Project, we always see two modules:
  1. Bundle
  2. Content
modules.PNG
Fig- Initial modules provided by maven-archetype

These modules are defined under parent Pom.xml.
modules.PNG
Fig- Modules configuration in parent Pom.xml

Problem Statement: I want to create multiple bundles in the same AEM Project. The use cases of doing this can be:

  • Need a bundle to run in publish instance only or need to deploy a bundle on the basis of specific locations.
  • Want to create multiple bundles in a single project on the basis of big functionalities like Login Module, Payment Module etc.


Solution: It is very easy, you just need to follow the below Steps:
  • Create the new bundle by just copying the existing bundle of a project.
add a new bundle.PNG
Fig - New Bundle created by copying the existing bundle

  • Rename the bundle1 ( i.e., test) .Now In Pom.xml of Test bundle change the ArtifactID (Because artifact should be unique for each module of the project).
newbundle.jpg
Fig- Rename the copied bundle and change the artifact id in Pom.xml of new bundle

  • Change the “Bundle-SymbolicName”  in the Test Module Pom.xml.
change-symbolic-name.jpg
Fig- Change the Bundle-SymbolicName in Pom.xml of Test Module

  • Add a new module in parent Pom.xml.
Fig- Adding Test Module in Parent Pom.xml

  • Content Pom.xml  contains the dependency of all the bundles, so we need to add the dependency of the new bundle(test-module) in this Pom.xml
add dependency.PNG
Fig- Add the dependency of Test Bundle in Content(ui.apps) Pom.xml

  • For deploying the bundles at any specific location we need to specify the location in the "target" (like install) and bundle ‘s groupId and artifactid in the embedded section.
deploy.PNG
Fig- Configuring the embedded section in Content(ui.apps) Pom.xml

  • Now you just need to build the code and you can find the bundle’s jar at expected location as you configured in content Pom.xml in embedded section.
crx.PNG
Fig- Showing bundles at specific location
By following the above steps you can create n number of bundles in a single AEM project.


Find the git repository from here .


If you have any query or suggestion then kindly comment or mail us at sgaem.blog02@gmail.com.


Thanks and Happy Learning 😊




1 comment:

  1. Great Article. Thank you for sharing! Really an awesome post for every one.

    IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

    Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
    Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

    ReplyDelete