Debug with dependency in Eclipse

Tags: #<Tag:0x00007f6171948098> #<Tag:0x00007f6171a23f08> #<Tag:0x00007f6171a23df0>

Hallo,
I am developing both a new binding and a lib to which the binding depends.
I am using Eclipse for both projects.

If I make a change to the lib code, I need to:

  1. mvn clean install the lib project to produce a new lib jar
  2. copy the lib jar to the /lib dir of the binding
  3. change some code to the binding, so that its jar gets re-build and used in the next demo.app run.

This manual work makes working/debugging on both the lib and the binding a bit complicated and less efficient.

Is there a better way to work on a lib and binding from Eclipse and keep everything in synch and maybe even with Hot Code Replace (triggered by lib and/or binding code changes) while running demo.app ?

Before bndtood and the new buildsystem this was indeed possibile: it was enough to add the lib project in the Build Path of the binding project (which I already did, with no improvement).
(of course I already followed the IDE Setup and Adding Dependencies - Internal dependency case in the developers guide)

thanks for your help!

I would expect if you make your lib an osgi enabled library you should be able to add it to the demo project app.bndrun, like a binding. Than it’s independent of your binding and no need to copy the jar to the lib. Your binding should be use it as an external library, include it in maven pom.

1 Like

The /lib directory should not be used anymore and I would suggest to remove it entirely for OH3.

Thanks @hilbrand and @J-N-K for the quick answer!
Indeed that is the final goal: have the lib as a bundle, publish it somewhere (where?) and make the binding depend on it.

Can you point me to examples of a binding in OH2 that does that or to a guide to make the process as easy as possible?
Which tool would you recommend? Or is it possible to do it editing manually the MANIFEST file? I am surely no OSGi expert and an advice here is really appreciated.

Or maybe I should leave transform it to bundle for OH3 and stick with /lib directory until my binding is first approved for OH 2.5.x ?
I have seen few bindings still have the /lib folder, so maybe this is still supported?

thanks

Which have still /lib? I think I removed them all.

I’m not sure if this fits your need, but in the Jython helper library add-on PR, I created a maven package for the Jython helper libraries and published it to Bintray. I then added it as a dependency in the pom. At first, I did created the package using GitHub Package, but Bintray was a little easier to get the hang of and the documentation was much better.

2 Likes

Thanks @J-N-K and @5iver for your suggestions.
In fact i got confused: I would avoid to make my lib an OSGi-enabled lib or even an OH add-on to offer its functionality.

I am just separating the protocol code provided by the lib from my binding code.

I have seen there are few bindings with jars in /lib, for example: cbus or rfxcom but I understand this is the old/wrong configuration and will be eliminated.

I see there are other bindings with dependencies to ext. libs that are declared using maven and are not OSGi bundles.
I have followed the guide in the Developer docs - Build system but I receive an error when I try to resolve dependencies with Bnd Tools (the lib I am developing depends itself on 2 libs: slf4j-log4j12 and nrjavaserial, both declared in the lib pom.xml and both should be already provided by the OH core):

Resolution failed. Capabilities satisfying the following requirements could not be found:
    [<<INITIAL>>]
      ⇒ osgi.identity: (osgi.identity=org.openhab.binding.openwebnet)
          ⇒ [org.openhab.binding.openwebnet version=2.5.6.202006212239]
              ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.openwebnet))
    [slf4j.log4j12 version=1.7.28]
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.slf4j)(version>=1.7.28))

Can you point me to the right instructions/examples on how to include in a new OH binding an external lib (just using maven)?

Thanks
Massimo

Are you sure this is provided by OH core? It should also be the same version as OH core.

I changed to the same slf4j-log4j12 lib version found in OH2.

However i think this can be closed, as the solution here is to make the lib an OSGi one and import with pom.
As I am having troubles with that, will open a new thread to ask support.
thanks