3rd party Maven dependencies in openhab core

Here are my findings so far (including some advise here):

  • “private” core dependencies (read: only relevant for the bundle itself, not to used by any other) are compiled into the classes output using the maven-dependency-plugin. Refer to the core audio bundle for an example
  • core dependencies that might be relevant for others should be declared as features. One could theoretically use Karafs wrap feature here but this “causes issues when for instance debugging the code in non-Karaf environments. E.g. it won’t work when running the Demo App in Eclipse.”
  • when developing bindings, its enough to declare the dependency in the POM with scope “compile” to have it compiled (“embedded”) in the resulting JAR. Refer to Build System | openHAB. Note the diff between the screenshot and the description: scope “compile” works here.
    • note that optional transitive dependencies are apparently not included in the compile output. But their packages ARE generated into the bundles manifest file ([compile output]/classes/META-INF/MANIFEST.MF) as Import-Package and will consequently fail the verify step during build. You have to tell BND that they are optional by adding a corresponding bnd.importpackage property to the POM.

      <properties>
      <bnd.importpackage>com.optionalpackage.*;resolution:=optional</bnd.importpackage>
      </properties>

4 Likes