March 30, 2020
Estimated Post Reading Time ~ 3 mins

Create Multiple Bundles in an AEM Maven Project

In AEM, Maven provides multi-module architecture.

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

In this blog, we will discuss 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
.com/
Fig- Initial modules provided by maven-archetype

These modules are defined under parent Pom.xml.
.com/
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.
.com/
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).
.com/
Fig- Rename the copied bundle and change the artifact id in Pom.xml of a new bundle
  • Change the “Bundle-SymbolicName”  in the Test Module Pom.xml.
.com/
Fig- Change the Bundle-SymbolicName in Pom.xml of Test Module
  • Add a new module in parent Pom.xml.
.com/
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
.com/
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.
.com/
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 the expected location as you configured in content Pom.xml in embedded section.
.com/
Fig- Showing bundles at specific location
By following the above steps you can create n number of bundles in a single AEM project.
aem4beginner.blogspot


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.

Ad Blocker Detected :(

Please consider supporting us by disabling your ad blocker.

Please Disable your adblocker and Refresh the page to view the site content.