Friday, September 15, 2023

Leveraging 3rd Party Packages in AEM as a Cloud

 In this post, let us explore how to deploy and use third-party (external) package bundles into the AEM as a Cloud platform.

Most of the time, we must embed third-party packages into the AEM platform to enable tool-specific functionalities. In AEM versions other than AEM as a Cloud platform, the external packages can be directly installed through the package manager without any issues. But in AEM as a Cloud platform, due to the architecture change, the package that has immutable content, e.g., /apps, are not allowed to be installed through package managers and should be part of the code deployment; some of the Adobe-supported external packages like CIF add-on, Core Components, and ACS Commons packages are enabled through Cloud Manager in AEM as a Cloud platform.

Let us understand how the external packages can be enabled for AEM as a Cloud platform.

Let’s start with the package/bundle hosted through an external repository.

As a first step, add the external repository where the package is hosted to the parent pom.xml and the existing Maven repositories.

<repositories>

.............

<repository>
<id>project.local</id>
<name>project</name>
<url>https://test.repo.com/repository</url>
</repository>

</repositories>

Now add the package or bundle dependency to the all/pom.xml (the version can be managed through the parent pom property)

<dependency>
<groupId>com.test.components</groupId>
<artifactId>com-test-components.all</artifactId>
<version>1.0.0</version>
<type>zip</type>
</dependency>

Now add the embed as part of the filevault-package-maven-plugin in all/pom.xml.

<plugin>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>filevault-package-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<group>com.test</group>

.............

<embeddeds>

................

<embedded>
<groupId>com.test.components</groupId>
<artifactId>com-test-components.all</artifactId>
<type>zip</type>
<target>/apps/test-vendor-packages/container/install</target>
</embedded>

</embeddeds>
</configuration>
</plugin>

Now, while deploying the code, the external package will also get deployed to the AEM as a Cloud server. Ensure the external package follows the AEM as a Cloud best practice for their packages; the package may not function as expected in AEM as a Cloud.

Sometimes, you may not have the package stored in the external repository, but if the package is locally available, you need to follow some additional steps.

Create a folder with the name repository under the root of the project.

Now install the local package/bundle to the project repository

mvn install:install-file -Dfile=<Local Package path> -DgroupId=<Group ID of the external Package> -DartifactId=<Artifact ID of the external Package> -Dversion=<Version of the external Package> -Dpackaging=<Packing Type of the external Package> -DlocalRepositoryPath=<Project Repository Folder Path>
mvn install:install-file -Dfile=C:\Test\com-test-components.all-1.0.0.zip -DgroupId=com.test.components -DartifactId=com-test-components.all -Dversion=1.0.0 -Dpackaging=zip -DlocalRepositoryPath=C:\Projects\AEM\mysite\repository

Now, the package will be installed in the project repository.

Update the repository location in parent pom.xml to point to the local project repository; the remaining steps are the same.

<repositories>

.............

<repository>
<id>project.local</id>
<name>project</name>
<url>file:${maven.multiModuleProjectDirectory}/repository</url>
</repository>

</repositories>

Now, while deploying the project through the Cloud Manager pipeline, the external package also gets installed to the AEM as Cloud servers.

No comments:

Post a Comment