Fragile build environment -- maven build fails

Hello *,

I just wanted to extend my openHAB-add-on – and yet again, my IDE started up completely red – full of error-markers. Nothing worked.

So, I set up a new workspace, new Eclipse IDE, all fresh, following your web-page:

I cloned the openhab-distro, openhab-core and openhab2-addons git repositories and imported all the projects into my IDE. I updated the target platform and all seemed good – only 2 error-markers in projects which I didn’t care about. Everything else was fine.

Thus, I cloned my own add-on’s git repo and imported the project. Ran the maven-build (after adapting the version from 2.1 to 2.4) and … it failed!

Well, so I thought I give your own add-ons a try and started a maven build (install) on one of your addons. It failed, too! I tried the same on openhab-core – again it failed. WTF?!

Anyway, I thought I don’t really want to upgrade my productive environment. So I looked in your repos what branches are available and saw the 2.2.x branch. Thus I switched to this older branch. But now, I could not update the target platform. It fails to find a bunch of org.eclipse.smarthome features and plugins.

Hence, I just switched back to master. Now, I could successfully update/reload my target platform and most projects don’t have error-markers, anymore.

But if I run a maven build on openhab-core (right-click its pom.xml => Run as … => Maven install), it fails:

[INFO] --- tycho-compiler-plugin:1.2.0:compile (default-compile) @ org.openhab.core ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:03 min
[INFO] Finished at: 2018-09-28T12:26:52+07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.2.0:compile (default-compile) on project org.openhab.core: Execution default-compile of goal org.eclipse.tycho:tycho-compiler-plugin:1.2.0:compile failed: Plugin org.eclipse.tycho:tycho-compiler-plugin:1.2.0 or one of its dependencies could not be resolved: Failed to collect dependencies at org.eclipse.tycho:tycho-compiler-plugin:jar:1.2.0 -> org.eclipse.tycho:tycho-compiler-jdt:jar:1.2.0 -> org.eclipse.jdt:org.eclipse.jdt.core:jar:3.13.102 -> org.eclipse.platform:org.eclipse.core.resources:jar:[3.12.0,4.0.0): No versions available for org.eclipse.platform:org.eclipse.core.resources:jar:[3.12.0,4.0.0) within specified range -> [Help 1]

I’m stuck, now, and cannot integrate my new solar system (PV inverters+chargers) :frowning: :crying_cat_face:

Finally, it’s time for a serious complaint: I really like openHAB and it runs stable controlling all the stuff in my house for over a year, now. But developing an add-on is a real nightmare! The very fragile build environment breaks again and again. It’s always the same: If I need to extend my add-on, I first need to waste at least half a day to get the build running again. And usually I’m also forced to update to the newest openHAB version, as well.

And today, even the newest version doesn’t work at all.

Why is it so hard to set up an environment that does not break time and again by itself? Or is it already possible to develop an add-on for a stable openHAB-release and I just don’t know how? I mean develop not against the git master but against a stable branch? If it is possible, how? And why does it not work with the 2.2.x git branch? And why is there no 2.3.x branch? Shouldn’t there be a branch for each release?

Best regards, Marco.

I just tried it again after checking out the tag “2.3.0”. The error is the same as with the branch “2.2.x”:

The target platform is broken, hence I cannot use it for development :frowning:

It’s almost impossible to get a working build in Eclipse.

I build with Maven out of master.

Thanks a lot for your quick reply, but it seems you totally misunderstood. Hence again:

The maven build is broken!

Both my old version (built against openHAB 2.1) and the newest version (checked out from scratch yesterday, thus building against 2.4) fail when running maven’s install. Yesterday’s error was already described in my initial post (see above). The error of 2.1 is slightly different – but also a dependency problem.

And this is not the first time. It always breaks after a while – and never because I changed anything, but always because the openHAB community is not managing the repositories / build environment properly.

See here: Build #87 on our build server.

[ERROR] Cannot resolve project dependencies:
[ERROR]   Software being installed: org.openhab.binding.intellihouse 2.0.0.qualifier
[ERROR]   Missing requirement: org.eclipse.smarthome.core 0.10.0.201809271800 requires 'package javax.measure 0.0.0' but it could not be found
[ERROR]   Cannot satisfy dependency: org.eclipse.smarthome.config.core 0.10.0.201809271800 depends on: package org.eclipse.smarthome.core.common 0.0.0
[ERROR]   Cannot satisfy dependency: org.openhab.binding.intellihouse 2.0.0.qualifier depends on: package org.eclipse.smarthome.config.core 0.0.0

This build was running fine the last time I changed sth. in our add-on (December 2017).

Also, I have worked a lot with Eclipse / OSGi in the past. It definitely is possible to keep such an environment functional. Of course, I have to admit, that it is not easy, because P2 sucks – it’s a misconception (as always when big companies like IBM design an architecture). But it can be done.

In the last project I worked with Eclipse+OSGi, we switched P2 repositories with every release (and if I remember correctly, Eclipse does the same).

And our snapshot-repository was ditched and rebuilt every month or so. This is of course a workaround, but given that we cannot change/replace P2 when working with such environment, it is the only well-functioning solution.

Additionally, what makes things worse, is that openHAB breaks APIs with every release. Hence, I cannot easily develop my add-on in Eclipse against e.g. 2.2 and build with maven against 2.1. The last time, I did this – using reflection to work around the changed methods. But now, it seems there are even classes renamed or replaced.

Well, the OH2 CI build is running fine.

Thanks again for the quick response.

However, the CI build seems to have run the last time on 2018-09-26, which is 3 days ago. Are you sure that it is still running fine?

And didn’t it become clear that I also (and primarily) complained that building older versions (i.e. not git master) is not possible?

It is common in software development that downstream projects do not build on the newest development version of the upstream project (e.g. because it is too unstable or because the downstream project lacks the resources to adapt to every API change every week or so). Instead, often an older, stable version is used. This, however, seems unfortunately to be impossible with openHAB.

I have made the experience multiple times (the 3rd time right now) that a build set up against a certain openHAB version (in my case: 2.0) breaks after a while (the 1st time: a few weeks). Updating and building against the next version (2.1) worked fine for a few months – and again suddenly broke. So, now I have to again switch to a newer version.

This is not normal!

You should really make sure that it is possible to build against older (stable) release versions – which are currently in productive use. Fixing a minor bug in a downstream project (e.g. my add-on) should not force people to upgrade to the newest unstable (development) version (a.k.a. git master)!

I pulled the latest master and built the core via mvn install. No issues here.

The only suggestion I can make at this point is to try clearing your m2 cache.

It’s always someone else’s fault :wink:

Anyway…

Check the error report -:

This is caused by a missing dependency - from the report, it seems your original binding is quite old and there are new dependency requirements now. In this case, it’s the unit of measure additions. You can find information on this in the following link - this shows the dependencies you need to add.

https://www.eclipse.org/smarthome/blog/2018/02/22/units-of-measurement.html

Good luck - I know it can be challenging, and I certainly sympathise as there is a lot of variability within the project at times.

Long time ago, but still would like to answer: I do not depend on javax.measure. This is a transitive dependency! The problem is thus not caused by any outdated dependency on my side.

If I do not modify any of my code at all, but it still breaks after a while (when I just trigger the build on Jenkins), even though I depend on a stable (not snapshot) version of OpenHAB, then obviously OpenHAB’s dependency/build-management is the sole cause for the problem.

And sorry: This should never happen! If a downstream project depends on a stable upstream-release, it must never break – unless a nature catastrophe causes dataloss or similar :wink:

This is not so. You’re neglecting the build environment / IDE, which can also cause build failures.

“X should never happen” may be true, but it’s also not worth saying. No system ever designed works without error.