Maven help - including including external project/pom.xml into binding

Hopefully there’s a maven guru (@maintainer) around as what I’m trying to do is way more advanced than my knowledge of maven!

Short version: is there a maven setting or plugin I can use to get a binding jar to include a dependency (a library jar that’s now a local artifact) when the binding is being built without hardcoding it in the bin.includes?

Long version: My Orvibo S20 binding uses a core standalone library I wrote that I’ve pushed to github as a maven project. Instead of having to rebuild, copy the library local to the binding and then amend the manifest and build path each time I make changes to the library, my hope was that I could somehow use my github releases for the library as a maven artifact so that I’d only need to change the release version in the pom when building.

I came across jitpack.io which allows me to do this. As far as I understand it does this by going to your stated github repo, downloading and building the project and saving the resulting artifact in your local maven repo. As part of this I removed the hard coded entry from the bin.includes section in the build.properties file. Having removed this, the binding builds without errors but no longer has the library jar included (not a surprise given that I’d just removed the line telling it to) and thus you get the NoClassDef exceptions thrown at runtime.

Thanks

The easier approach would be to not include the standalone core library in your bundle, but to change your core library to be a valid OSGI bundle and deploy it separately.
In openHAB you can define a Karaf feature, which includes both your bundle and the core library dependency, so that they are bundled and installed together.
Have a look at https://github.com/openhab/openhab2-addons/blob/master/features/openhab-addons/src/main/feature/feature.xml for examples.
This way, all you would have to change to include a different version of the core library is the feature.xml.
Turning the core library into an OSGI bundle allows you to deploy different versions of your core library in the runtime without having to rebuild/redeploy your openHAB addon.

Hi Davy

The main reason I created the library instead of writing the code in the binding is so that it could be reused in other applications if someone happens to find it useful.

If I create it as an OSGi bundle how easy it for non-OSGi applications to reuse the bundle?

If I create it as an OSGi bundle how easy it for non-OSGi applications to reuse the bundle?

It would be exactly the same as it is now. Enabling your jar for OSGI only requires adding some OSGI required info into the manifest.