Expand my Community achievements bar.

SOLVED

Embedding multiple version of the same OSGI dependency

Avatar

Level 1

Hello !

I have an issue with some bundle who remain inactivated (let's call it BundleX) because of an unresolved package import on a specific version of Google Guava. Guava is actually present in the OSGI container, but with a version that satisfy another dependency of the project (MyBundle).

So I have:

project-content-package

-> MyBundle

    -> Guava:15.0 ( I do need this version for some features)

-> BundleX

    - Guava:r06 (r06 < 15.0. I don't have the control on this bundle)

 

When making my content package, I'd like to embed all osgi dependencies, and to solve my problem, embed the two guava versions. As we know, OSGi supports multiple versions of packages deployed at the same time.

Until now, in my AEM content package pom configuration, I had:

<plugin> <groupId>com.day.jcr.vault</groupId> <artifactId>content-package-maven-plugin</artifactId> <configuration> <embeddeds combine.children="append"> <embedded> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <target>${cq.slingUrlSuffix}</target> </embedded> ... </embeddeds> ... </configuration> ... </plugin>

The version of the embedded dependency is determined by maven and of course is unique for this maven project.

So, to sum up, to solve by problem, I should:

- embed multiple versions of Guava in osgi container. The only solution I see is creating another artifical content package pom just to upload the other Guava dependency. But it's far to be optimal since I'd like my main package to contain all embedded osgi dependencies.

- override the version of the dependency of bundle2 from r06 to 15.0, so I need only Guava 15.0 in my container. Since I don't have the control on this bundle, I should override that from outside, but I have no idea if it's possible to do that.

 

In advance, thank you very much for your help !

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

In your case I would embed the guava 15.0 libraries in your application bundle, as it's likely the easiest way to solve this issue. For Bundle X you can place it in the OSGI container.
(Or you can also wrap BundleX into a custom BundleY, which holds BundleX plus the Guava library used...)

kind regards,
Jörg

View solution in original post

4 Replies

Avatar

Level 10

I would create an OSGi bundle that contain just the  Google Guava API and get that bundle into an active state. Once active - it will satisfy the dependency for BundleX. 

Avatar

Level 10

Yes.. So each bundle can have a dependency of different version jar and all the version jar should be available in the OSGi container so it refers its respective versions.

Avatar

Correct answer by
Employee Advisor

Hi,

In your case I would embed the guava 15.0 libraries in your application bundle, as it's likely the easiest way to solve this issue. For Bundle X you can place it in the OSGI container.
(Or you can also wrap BundleX into a custom BundleY, which holds BundleX plus the Guava library used...)

kind regards,
Jörg

Avatar

Level 10

else, in your pom you can also mention to refer the version like 1.x or more . refer [1] for various options

[1] https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html