Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

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

Avatar

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

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

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>

 

Avatar

Level 2

Hi @BrianKasingli 

 

How can you do your second step?

 

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>

 

I´m trying but it shows me this error: 

 

[ERROR] ValidationViolation: "jackrabbit-packagetype: Package of type 'APPLICATION' is not supposed to contain OSGi bundles or configurations!", filePath=jcr_root\apps\catalog\install\org.apache.sling.dynamic-include-3.3.0.jar, nodePath=/apps/catalog/install/org.apache.sling.dynamic-include-3.3.0.jar

 

I´m doing it in the ui.apps pom in the following pluging, am I wrong?

 

<plugin>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>filevault-package-maven-plugin</artifactId>
<configuration>
<properties>
<cloudManagerTarget>none</cloudManagerTarget>
</properties>
<group>com.hdr.catalog</group>
<name>catalog.ui.apps</name>
<packageType>application</packageType>
<repositoryStructurePackages>
<repositoryStructurePackage>
<groupId>com.hdr.catalog</groupId>
<artifactId>catalog.ui.apps.structure</artifactId>
</repositoryStructurePackage>
</repositoryStructurePackages>
<dependencies>
</dependencies>
<embeddeds>
<embedded>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.dynamic-include</artifactId>
<target>/apps/catalog/install</target>
</embedded>
</embeddeds>
</configuration>
</plugin>

 

Thank you all for your help!