Adding third party dependencies in maven | Community
Skip to main content
Level 2
June 10, 2021
Solved

Adding third party dependencies in maven

  • June 10, 2021
  • 4 replies
  • 3835 views

I am using Microsoft Graph api and would like to know how to add that dependency in maven.  I have tried with below entries but not working as expected. 

 

Added below entry in dependencies

<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
<version>3.2.0</version>
</dependency>

 

And added embed dependency entry in profiles as below...

<Embed-Dependency>microsoft-graph</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>

 

No compilation issues. It's throwing dependency errors when I deploy it to aem6.5. Looks like it's not resolving the recursive dependencies. 

 

Any help on this is greatly appreciated..

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Bhuwan_B

@kgiribabu Please follow the steps mentioned in below community article :

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-bundle-third-party-libraries-or-bundles/qaq-p/244592

1. Add dependency to the pom.xml

<dependency>

<groupId>com.thirdparty</groupId>

<artifactId>my-bundle</artifactId>

<version>1.0.0</version>

<scope>system</scope>

<systemPath>${project.basedir}/../repo/thirdparty.jar</systemPath>

</dependency>

if you have the bundle in your system , you can simply give the path to that bundle using the scope 'system'. Here, the folder 'repo' is besides the bundle folder in the project structure.

 

2. In your maven bundle plugin configuration in pom.xml, add the jar to the embed-dependency option like that:

<plugin>

<groupId>org.apache.felix</groupId>

<artifactId>maven-bundle-plugin</artifactId>

<version>2.3.7</version>

<configuration>

<instructions>

<Embed-Dependency>*;scope=system</Embed-Dependency>

</instructions>

</configuration>

</plugin>

 

3. Build the maven project

 

4 replies

ibishika
Level 4
June 10, 2021
Bhuwan_B
Community Advisor
Bhuwan_BCommunity AdvisorAccepted solution
Community Advisor
June 11, 2021

@kgiribabu Please follow the steps mentioned in below community article :

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-bundle-third-party-libraries-or-bundles/qaq-p/244592

1. Add dependency to the pom.xml

<dependency>

<groupId>com.thirdparty</groupId>

<artifactId>my-bundle</artifactId>

<version>1.0.0</version>

<scope>system</scope>

<systemPath>${project.basedir}/../repo/thirdparty.jar</systemPath>

</dependency>

if you have the bundle in your system , you can simply give the path to that bundle using the scope 'system'. Here, the folder 'repo' is besides the bundle folder in the project structure.

 

2. In your maven bundle plugin configuration in pom.xml, add the jar to the embed-dependency option like that:

<plugin>

<groupId>org.apache.felix</groupId>

<artifactId>maven-bundle-plugin</artifactId>

<version>2.3.7</version>

<configuration>

<instructions>

<Embed-Dependency>*;scope=system</Embed-Dependency>

</instructions>

</configuration>

</plugin>

 

3. Build the maven project

 

Asutosh_Jena_
Community Advisor
Community Advisor
June 11, 2021

Hi @kgiribabu 

 

Everything looks good here. Only one item is missing which you need to add in your ui.apps POM.xml file. This is just to install the 3rd party jar on your AEM instance.

Please embedd the external JAR at the same location where you have embedded your project specific jar file i..e under "content-package-maven-plugin".

 

<embedded>
      <groupId>com.microsoft.graph</groupId>
      <artifactId>microsoft-graph</artifactId>
      <target>/apps/yourprojectname/install</target>
   </embedded>

 

If you do not want to follow the above process, you can manually install the JAR on OSGi at "http://localhost:4502/system/console/bundles" as well.

 

Thanks!

 

Vijayalakshmi_S
Level 10
June 11, 2021

Hi @kgiribabu,

Only correction needed in <Embed-Dependency> entry.

It has explicit mention of artifactId "microsoft-graph" alone to be included/embedded as part of core bundle. 

 

Please use "*" which includes/embed all of its transitive(compile and/or runtime) dependencies along with core bundle. 

<Embed-Dependency>*</Embed-Dependency> // This will include all maven dependencies as available in parent pom.xml/core pom within <dependencies> entry.

 

If you still face issues in few dependencies resolving/ NoClassDefFound Error at the time of execution/testing the functionality even when the bundle is active, please update this thread with respective dependency details.