Including Adobe Target SDK in Custom OSGI Bundles | Community
Skip to main content
Level 3
June 7, 2022

Including Adobe Target SDK in Custom OSGI Bundles

  • June 7, 2022
  • 1 reply
  • 2451 views

Hello.

I have a custom OSGI bundle deployed to an AEM 6.5 instance. I wanted to include the Adobe Target Java SDK in the project (so it can be utilized by another service class).

 

I have added it to my pom.xml:

 

<dependency> <groupId>com.adobe.target</groupId> <artifactId>target-java-sdk</artifactId> <scope>compile</scope> </dependency>

 

 

However, after publishing the package, I see the following error in the Web Console:

com.adobe.target.delivery.v1.model -- Cannot be resolved
com.adobe.target.edge.client.model -- Cannot be resolved

 After noting this error, I configured the maven-bundle-plugin as follows:

 

<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <configuration> <exportScr>true</exportScr> <instructions> <Embed-Dependency>target-java-sdk;scope=compile|runtime</Embed-Dependency> <Embed-Transitive>true</Embed-Transitive> </instructions> </configuration> </plugin>

 

 

However, this led to another set of errors relating to dependencies used by the Target SDK (json-logic-java, unirest-java, etc). I added those to the `Embed-Dependency` option and then got another error for another set of dependencies.

 

So, rather than having to explicitly include an endless chain of dependencies, I am would like to know that is the recommended practice for integrating the Target SDK with AEM? Does Adobe provide OSGI bundles for the SDK?

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

1 reply

SantoshSai
Community Advisor
Community Advisor
June 7, 2022

Hi @kmarchewa ,

The best way to install the Adobe Target Java SDK is to embed the bundle into your. here's instructions on how to do it:

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 Adobe Target Java SDK as a dependency in the ui.apps pom.xml

<!-- Adobe Target Java SDK -->
<dependency>
<groupId>com.adobe.target</groupId>
<artifactId>target-java-sdk</artifactId>
</dependency>

2. Embed the Adobe Target Java SDK as a package for deployment in ui.apps/all pom.xml

<embedded>
<groupId>com.adobe.target</groupId>
<artifactId>target-java-sdk</artifactId>
<target>/apps/my-site/install</target>
</embedded>

3. Include the Adobe Target Java SDK as a dependency in the parent pom.xml

<!-- Adobe Target Java SDK -->
<dependency>
<groupId>com.adobe.target</groupId>
<artifactId>target-java-sdk</artifactId>
<version>2.3.0</version>
</dependency>


 Hope that helps!

Regards,
Santosh

Santosh Sai
KMarchewaAuthor
Level 3
June 7, 2022

Thanks much for the quick response. Unfortunately, this app does not have a `ui.apps` directory (it is a mature code base and I assume was not built using the current maven archetype). Is there an alternative for such a project? Thanks much.

KMarchewaAuthor
Level 3
June 7, 2022

@kmarchewa 
May I see your project structure? where your AEM components are present? If you have old version maven archetype please visit this article https://www.techinnovia.com/osgi-bundle-lifecycle/ in video we have described hoe to do that.


Sure. Please see attached.

Basically, the front-end code (html, client libs, JCR related nodes/XML) is under "packages". The Java code is under "bundles" with three further subprojects of "providers", "services" and "servlets". The Target SDK is used directly in "bundles/services"; the Service class that utilizes the SDK is then consumed in a class under "bundles/providers". Both the "bundles/services" and "bundles/providers" bundles are the ones giving the error (and that I added the SDK dependency too). Hope that makes sense. Thanks!