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
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:
Message: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=openhab-binding-enera; type=karaf.feature; version=2.5.4.SNAPSHOT; filter:="(&(osgi.identity=openhab-binding-enera)(type=karaf.feature)(version>=2.5.4.SNAPSHOT))" [caused by: Unable to resolve openhab-binding-enera/2.5.4.SNAPSHOT: missing requirement [openhab-binding-enera/2.5.4.SNAPSHOT] osgi.identity; osgi.identity=org.openhab.binding.enera; type=osgi.bundle; version="[22.214.171.124004010832,126.96.36.199004010832]"; resolution:=mandatory [caused by: Unable to resolve org.openhab.binding.enera/188.8.131.52004010832: missing requirement [org.openhab.binding.enera/184.108.40.206004010832] osgi.wiring.package; filter:="(osgi.wiring.package=com.sun.org.apache.xpath.internal)"]]
Thank you very much @ssalonen!
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-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