I’m currently building a binding for the Enera project (https://projekt-enera.de/).
Because they are using AWS Cognito as their Identity Provider, I tried to add the aws-java-sdk as a dependency.
As the SDK is huge, Amazon provides the possibility to add only certain modules as dependencies (see the docs).
Unfortunately, the standard SDK is not OSGi compatible, which leads to errors about missing requirements. They do provide an OSGi compatible package for the 1.x version of their SDK, but this does not allow for modular dependencies, and also is not available for 2.x.
As Java is not my usual battle ground, I’m a bit lost and am hoping for help…
I’ve not tried it myself but the documentation suggests that you can ask for a dependency to be “wrapped” to make it OSGi compatible by adding something to src/main/feature/feature.xml:
Hours of trial and error later, I now have almost all dependencies needed to communicate with Cognito included. The problem does not seem to be the OSGi compatilibity, but the fact that Maven does not see (and resolve) all dependencies that Karaf sees.
I now have >15 manually added dependencies inside my pom.xml.
Additionally, I’d need to create a file etc/custom.properties to resolve dependency to the package com.sun.org.apache.xpath.internal, and I am not sure I am allowed to do that in the openHAB context. Also, I didn’t get this to work, so the verify step keeps complaining:
Your hint to look at the pom.xml for the dynamodb persistence bundle sent me down the right track.
To summarize, things I learned (from the standpoint who barely understands the complexity of OSGi, Karaf, its features, dependency management of maven etc…):
in contrast to having a maven-only project, one has to include many dependencies manually: in my test project I only needed dependencies to aws-java-sdk-cognitoidentity and aws-java-sdk-cognitoidp, in the OSGi world, I needed to include 18 dependencies!
for all packages that need to be resolved using the JDK libs, instead of using the documented way outlined above (creating etc/custom.properties etc.), the <bnd.importpackage> directive in pom.xml seems to also satisfy the verify build step
So, after 2 days of hard work I can actually start working on the binding