How to bundle third party libraries or bundles | Community
Skip to main content
VeenaVikraman
New Participant
Jun 27, 2017 9:15 PM UTC
Solved

How to bundle third party libraries or bundles

Hi All

        Is it possible to bundle a third party bundle along with our project bundle through MAVEN? We have faced issues with this many times. Most of the time what i do is to directly install the third party bundle to Felix console and add the dependency to my POM. I am looking for a better approach than this in which everything goes in one shot (bundled in my project )as and when I install my package.

TIA

Veena

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Nupur_Jain
Nupur_JainAccepted solution
Employee
Jun 28, 2017 6:45 AM UTC

Hi Veena,

There is a way where you can just make the third party bundle part of the project bundle.

Suppose you have a third party bundle called 'thirdparty.jar'. Follow the steps :

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. Go to the target folder where you built bundle/jar is present, extract the jar, you will notice that the thirdparty jar is embedded in the bundle jar. I have attached the screenshot for your reference that shows the content of the extracted bundle containing the thirdparty jar.

Source image file 6576 not available

8 replies

aanchal-sikka
New Participant
Sep 27, 2023 9:52 AM UTC

Sharing a blog which explains how to use Third-party bundles when:

  • Hosted in restricted Maven repo
  • Local repo (i.e. when maven repositories cannot be used)

https://techrevel.blog/2023/09/27/managing-third-party-dependencies-in-aem/

 

It also covers the configs needed for deployment via Cloud manager

Translate
Aanchal Sikka
New Participant
Apr 28, 2023 3:34 PM UTC

Hi @nupur_jain, you mentioned ${project.basedir}/../repo/thirdparty.jar 

Here, the folder 'repo' is besides the bundle folder in the project structure

 

Where do I need to place the thirdpary jar? Should I create repo folder under core? This repo folder also should be committed in codebase?

 

Could you please clarify. Thanks in advance

Translate
Nupur_Jain
Employee
Jun 29, 2017 3:04 PM UTC

Glad it helped

Translate
VeenaVikraman
New Participant
Jun 29, 2017 3:01 PM UTC

Thanks Nupur It worked ...

Translate
VeenaVikraman
New Participant
Jun 28, 2017 3:00 PM UTC

Thanks Scott .

Translate
smacdonald2008
Level 10
Jun 28, 2017 1:46 PM UTC

We have this covered here:

HOW CAN I WORK WITH CUSTOM JARS THAT ARE NOT IN THE MAVEN REPOSITORY

In this blog post: Scott's Digital Community: Adobe Experience Manager FAQs and other Tips

Translate
VeenaVikraman
New Participant
Jun 28, 2017 11:45 AM UTC

I will try this out and let you know if this worked for me. Thanks for a quick turnaround

Translate
Nupur_Jain
Nupur_JainAccepted solution
Employee
Jun 28, 2017 6:45 AM UTC

Hi Veena,

There is a way where you can just make the third party bundle part of the project bundle.

Suppose you have a third party bundle called 'thirdparty.jar'. Follow the steps :

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. Go to the target folder where you built bundle/jar is present, extract the jar, you will notice that the thirdparty jar is embedded in the bundle jar. I have attached the screenshot for your reference that shows the content of the extracted bundle containing the thirdparty jar.

Source image file 6576 not available

Translate