External dependencies via Maven

Hi,

today I started working on a binding for openhab2. Since I don’t want to create everything from scratch I would like to add an external dependency via maven.

From the guide on ESH https://www.eclipse.org/smarthome/documentation/development/bindings/dependencies.html#rd-party-libraries it seems I would need to hard code the dependency (which seems odd…)

Is this really unsupported?

1 Like

Is this really unsupported?

Yes, this is how it is handles in openHAB for the past 6 years.
Changing it would require a complete change of the IDE setup and the Maven build.

Hi Kai,

thanks for the quick response. Could you explain why then the addon bundles all contain a pom file? From my perspective it would be at least useful to include dependencies as osgi bundles instead of using jar files in every addon.

Although I noticed most addons simply do their own implementation of a protocol instead of relying on external libraries.

1 Like

The build is done with Maven Tycho, which requires OSGi bundles to have a pom in order to be found and picked up by the Maven build. But their content is rather minimal.

This is done whereever possible, but it requires the dependency to be available in some p2 repository. See e.g. all dependencies that are taken from Eclipse Orbit.

Although I noticed most addons simply do their own implementation of a protocol instead of relying on external libraries.

This is clearly the preferred solution, since it keeps the bindings (and thus the runtime) lean and you do not end up deploying half the internet in the end.

Thanks for the explanations!

This sounds a lot like reinventing the wheel… But as long as it’s not enforced I guess there is no reason to discuss this :wink: