Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to package (SDI) JAR file into my AEM project?

Avatar

Level 4
What is the best way for me to embed Sling Dynamic Include bundle.jar into my AEM project? The documentation says include this as a dependency, but it does not work...

 

 

 

<dependency>
    <groupId>org.apache.sling</groupId>
    <artifactId>org.apache.sling.dynamic-include</artifactId>
    <version>3.1.2</version>
</dependency>

 

 

 

Apache Sling :: Apache Sling Dynamic Include

 

I found another blog article here too, but it does not work as well, Caching Common or Shared Content in AEM Using Sling Dynamic Include | by Sreenivas B | Adobe Tech Bl...

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You can do this easily (after building and deploying code into your AEM local, you should be able to find the jar file existing under /apps/my-site/install:

1. Include the SDI as a dependency in the ui.apps pom.xml

<!-- Sling dynamic include -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.dynamic-include</artifactId>
</dependency>

2. Embed the SDI as a package for deployment in ui.apps pom.xml

<embedded>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.dynamic-include</artifactId>
<target>/apps/my-site/install</target>
</embedded>

3. Include the SDI as a dependency in the parent pom.xml

<!-- Sling dynamic include -->
<dependency>
  <groupId>org.apache.sling</groupId>
  <artifactId>org.apache.sling.dynamic-include</artifactId>
  <version>3.1.2</version>
</dependency>

 

View solution in original post

4 Replies

Avatar

Community Advisor

Hi @AEMWizard 


If It is third-party library, recommended to embed it providing an instruction to the maven-bundle-plugin, for more details kindly follow my blog here https://www.techinnovia.com/package-import-and-export/ demonstrated practical demo video at the end.

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.


Reference: https://experienceleague.adobe.com/docs/experience-manager-learn/foundation/development/set-up-sling...


Hope that helps you!

Regards,

Santosh

Avatar

Level 4

sorry sir, but I am looking for a way to package 

org.apache.sling.dynamic-include

this project into my bundle. 

Avatar

Correct answer by
Community Advisor

You can do this easily (after building and deploying code into your AEM local, you should be able to find the jar file existing under /apps/my-site/install:

1. Include the SDI as a dependency in the ui.apps pom.xml

<!-- Sling dynamic include -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.dynamic-include</artifactId>
</dependency>

2. Embed the SDI as a package for deployment in ui.apps pom.xml

<embedded>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.dynamic-include</artifactId>
<target>/apps/my-site/install</target>
</embedded>

3. Include the SDI as a dependency in the parent pom.xml

<!-- Sling dynamic include -->
<dependency>
  <groupId>org.apache.sling</groupId>
  <artifactId>org.apache.sling.dynamic-include</artifactId>
  <version>3.1.2</version>
</dependency>