[SOLVED] Binding with 3rd pty libraries


i’d like to learn how to properly write new bindings. However, i don’t want to reinvent everything. For my usecase a java library is available which itself uses libraries which uses e.g. org.apache.commons:commons-lang3 which is currently not available in OH2. So where do i need to put this dependency?

  • There is a pom.xml, which is in my eyes the first place
  • There is a features.xml which may be used only in Karaf
  • Any other place?

From my knowledge, everything inside the project’s pom.xml will also be included in the binary distribution of my binding. But then a dependency would be available multiple times in a running system as Karaf is installing the same dependency again? Which is then choosen?

In this example: org.apache.commons:commons-lang (Version 2) is already available in OH2, is it allowed to use org.apache.commons:commons-lang3?

(Disclaimer: This is the first time i try to do something with OSGi - maybe i still did not get the basics - please point me somewhere if useful)

Thanks in advance

1 Like

It depends on your usecase and do you have good reasons for them. This is what the docs say:

But be warned. There are still some problems after build system change. Please read this github PR/issue about the newer Telegram binding:

1 Like

Thank you. Especially the PR discussion was worth a read.

For others TL;DR: Do not rewrite Libs, use libs if they make life easier and choose wisely the implementation. Karaf is providing the dependencies, which shall be marked as provided inside pom.xml.