Expand my Community achievements bar.

SOLVED

Adding third party dependencies in maven

Avatar

Level 2

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..

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-bundle-third-party-...

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

 

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

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

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-bundle-third-party-...

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

 

Avatar

Community Advisor

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!

 

Avatar

Level 10

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.