Adobe AEM Embedding Third Party Jar as Bundle
Adobe AEM Embedding Third Party Jar as Bundle
Options:
- 1. Eclipse Plugin Project to convert Jar into Bundle with manifest file
- 2. Install along with AEM application using Maven Embed
In the below given example I am using my custom Adobe AEM application which needs a third party jar file “jsoup.jar” in my case. I used archetype 27 for building this maven sample aem project.In your case it can be any third party Jar file required to integrate with Adobe AEM.
1. Eclipse Plugin Project
Step1: Open Eclipse IDE and select
File -> New à
Other à
Plugin from Existing JAR Archives
Step 2: In the next pop select external Jar as shown below and navigate to the downloaded third party jar in your local from maven repository.
Step 3: Provide project details as shown below for the new
jar added
Click Finish. It might take some time couple of minutes to build project depending on your JAR size.
Step 5: Go to Run time and select the required packages
which your application might require from this third party jar as shown below
Note:
In some cases there may be version numbers in imported
packages. If there are any version numbers with imported package please remove
it in manifest file and save
Step 6: Once the above steps are done. Now Go to the new plugin project we created in eclipse in above step and right click to “Export” and select “Deployable plug-ins and fragments” as shown below
Now select the path where you want to save the bundle jar
locally and click on finish. Now go to the specified location and you will find
the deployable bundle.
Step 8:
Now go to AEM Server system console bundle where you want to
install this bundle
http://localhost:4502/system/console/bundles
Example:
Click on “install/update” button on top right corner and navigate to the local bundle created in above step and install. Make sure the bundle is active once installed. In some case it may fail install in that case expand the installed bundle and look and any un resolved dependency as show below sample:
In such cases make sure the unresolved dependant jar file
also installed as osgi bundle using same steps mentioned above.
http://localhost:4502/system/console/depfinder
2.
Install along with AEM application using Maven Embed
Step 1: Search and Find the corresponding jar
version in maven repository
Example:
https://mvnrepository.com/artifact/org.jsoup/jsoup/1.14.1
<!--
https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.1</version>
</dependency>
Step 2: Add this jar as dependency to maven
Aem custom application pom.
In Root Pom add the below dependency of
jsoup.jar under dependencies section as shown below
<!-- ====================================================================== -->
<!-- D E P E N D E N C I E S -->
<!-- ====================================================================== -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.1</version>
</dependency>
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.versioning</artifactId>
<version>1.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.bundle</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.metatype.annotations</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
Step 3: Next in the pom.xml which is
located under your core folder add the below line of dependency for jsoup jar
as shown below
<dependencies>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
<scope>test</scope>
</dependency>
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.versioning</artifactId>
</dependency>
Step 4: Now add the embed line in pom.xml located
under all (all/pom.xml)
Look for the last embed snippet shown
below.Now Jsoup.jar will get added as external jar under folder path “/apps/sandboxsite-vendor-packages/application/install”
along with other vendor jar like core components etc..
<plugin>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>filevault-package-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<group>com.sandbox</group>
<packageType>container</packageType>
<properties>
<cloudManagerTarget>all</cloudManagerTarget>
</properties>
<!-- skip sub package validation for now as some vendor packages like CIF apps will not pass -->
<skipSubPackageValidation>true</skipSubPackageValidation>
<embeddeds>
<embedded>
<groupId>com.sandbox</groupId>
<artifactId>sandboxsite.ui.apps</artifactId>
<type>zip</type>
<target>/apps/sandboxsite-packages/application/install</target>
</embedded>
<embedded>
<groupId>com.sandbox</groupId>
<artifactId>sandboxsite.core</artifactId>
<target>/apps/sandboxsite-packages/application/install</target>
</embedded>
<embedded>
<groupId>com.sandbox</groupId>
<artifactId>sandboxsite.ui.content</artifactId>
<type>zip</type>
<target>/apps/sandboxsite-packages/content/install</target>
</embedded>
<embedded>
<groupId>com.sandbox</groupId>
<artifactId>sandboxsite.ui.config</artifactId>
<type>zip</type>
<target>/apps/sandboxsite-packages/application/install</target>
</embedded>
<embedded>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.content</artifactId>
<type>zip</type>
<target>/apps/sandboxsite-vendor-packages/application/install</target>
</embedded>
<embedded>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.core</artifactId>
<target>/apps/sandboxsite-vendor-packages/application/install</target>
</embedded>
<embedded>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.config</artifactId>
<type>zip</type>
<target>/apps/sandboxsite-vendor-packages/application/install</target>
</embedded>
<embedded>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<target>/apps/sandboxsite-vendor-packages/application/install</target>
</embedded>
</embeddeds>
</configuration>
Step 5: Build the Maven and Install the Package
Ø
mvn clean install -P autoInstallPackage -P
adobe-public
Once Deployed you can see the third party
jar installed as shown below along with your custom application
Comments