How do the dependencies work now?

Please help explain how the dependencies are figured out. The problem is need to use a newer version of jetty, which has some api changes. The original discussion about it is here: https://github.com/openhab/openhab2-addons/issues/6013
My IDE shows in maven dependencies an old version 9.3.25.v20180904. The new version 9.4.11 is however pointed to by various openHAB files, like app.bndrun and boom/runtime/pom.xml.
How can I make my build use the new version? How does the build figure out it has to use the old one and why?
I tried installing from scratch and it does not help.
Thank you
Pawel

There are different version defined for compile and runtime in openHAB-core. That is why you see different version. I think the reason it is an older version at compile time is to keep core more compatible for other users of openHAB-core. Runtime is openHAB specific. See https://github.com/openhab/openhab-core/search?l=Maven+POM&q=<jetty.version>

In this case it might be a reason to update the compile version in openHAB-core. You can open a pull request on core, with just that change. I checked and the new constructor with HttpClient seems to be added in 9.4. So either set ā€˜compileā€™ version to the current ā€˜runtimeā€™ version 9.4.11.v20180605 or the first version this constructor was added.

Thanks this explains it. I am only wondering why when I did not have openHAB-core at all it was choosing 9.3. I canā€™t find any reference to 9.3 in openhab2-addons or openhab-distro. Any ideas?

Iā€™m assuming you did have the openhab2-addons root pom via parent dependency of your binding pom and that refers to the openhab-core poms and gets the dependencies that way.

I think yes. These dependencies is what I see for all bindings. I did not really look into how this propagates upwards. I installed a fresh new IDE selecting only addons and distro as some time ago this was as advised to do and not core unless I wanted to develop core components. What does it mean for the IDE setup guide? If I want to develop the addons which options should I select when installing eclipse? I still need to check how it all works with core repo and compile boms, I will let know later.

Only if you want to develop on core you need core. In some very specific cases where a new version of a library provided via core needs to be updated you need core. But I donā€™t think this will be very common. So I think the advice still holds.

So where is that stored that a new or old version of a library has to be used for addons? If I look into .m2 I have even three versions of jetty libraries. Somehow the specific one is chosen over the others, if I donā€™t have openhab-core at all.

The .m2 is only a repository that caches all jars downloaded by maven and will contain all versions every downloaded. If you want to see the dependencies run the following command from within your binding project:

mvn dependency:tree

It will show all dependencies. Those dependencies are downloaded by maven when you run the maven command to the .m2 repository and maven links to those dependencies during building the sources.

So dependency for any binding in addons shows version 9.3. I am wondering where does this value come from. Changing the version in openhab-core bom does not impact anything. I suspect until it gets built and sucked in by the addons. But I donā€™t know it, Iā€™d like to understand how this works.

1 Like

I think Iā€™ve given you all necessary information to find out how this works, unless you miss some (basic) knowledge of how maven works. But I donā€™t think I can be of any help here without this becoming a crash course in how maven works. So I would suggest to read something about the basics of maven and than ask further questions on how openHAB uses maven. Here is a starting point:

Thanks, that book is what I needed, I donā€™t have a good knowledge of maven - this is my side fun activity and I learn a lot basic things. I will try to deconstruct how the dependencies in maven work for openhab.

I studied the book and I think I understand how it all works now and I have submitted PR to upgrade compile version of jetty and I will later start using it.
Thanks @hilbrand for helping me and being patient!

2 Likes

@hilbrand, one more question, on the building process this time, but related.
I installed 2.5 M3 milestone release on my Ubuntu. In runtime, the jetty version that implements HttpClient object which I can retrieve as common HTTP client in my thing factory (setHttpClientFactory reference), is in version 9.4.18.
The openhab-core/bom/runtime/pom.xml from M3 tag has jetty version 9.4.11
I can find version 9.4.18 only in features/karaf/openhab-core/pom.xml and features/karaf/openhab-tp/pom.xml.
Which pom is used for which builds?
I verified that I have to set jetty version in my binding exactly to 9.4.18 or it does not work. I could set it in bindingā€™s pom to ā€œcompileā€ scope, but I am not sure if this is right - it will likely need manual updating when the release version is upgraded to match it.
What would you advise to do?

I think that is the easiest way to move forward for now.