Errors with openhab3 fresh checkout with eclipse

  • Platform information:
    • Hardware: Macbook Pro 16 GB
    • OS: Mac Os Big Sur
    • Java Runtime Environment: Java 11_0_11
    • openHAB version: 3
  • Issue of the topic: errors after clean install via oomph / developers guide
  • Please post configurations (if applicable):

Dear experts,

I am still trying to convert the volumio2 binding written in OH2 to OH3, yet getting a clean workspace already costs me a lot of effort. I followed the Developers Guide (thanks a lot!) and was able to checkout OH Core, Add-ons and demo app via oomph installer in eclipse.

After the checkout and build process has completed, I still remain with 59 errors in throughout the build, generated in org.openhab.core.model :

“Project ‘org.openhab.core.model.item’ is missing required source folder” and more errors like this or derived from this. It also suggests to clean and build once again. Yet, this does not resolve the issue for me.

I’ve already tried several approaches within eclipse: fresh checkout / update maven project / build order fiddling…

Many thanks for sharing your knowhow!

Jan-Bernard

Note: The current code also does not build on my Windows setup.
Only when I skip the tests (it used to work in the past), not sure were to configure this in Eclipse.

As for your problem:
It might be the code-generation for model is not performed.
Running ModelGen.launch (again) could help here.

Some strong opinion on openHAB developer-friendlyness follows…

In general we should look at getting a better developer experience.

You should be able to checkout the project, fire up the IDE press play and be able to run a representative openHAB build including an option to add all the needed add-ons and set breakpoints and debug everywhere, preferably with edit & continue a.k.a. hot swap (it is 2021…)

The whole ‘enterprise’ setup with Maven & OSGI bundles makes things more complicated, but might actually help to support hot deployments, because that is what it was made for. Unfortunately it takes ages before a new bundle is build and packaged.

I like to use IntelliJ and I was not able to get the demo project running. I tried the official OSGI plugin, an Apache Felix plugin, Amdatu and a bdntools plugin, all giving differerent errors or just nothing running at all.

Furthermore I don’t think the demo project is the right approach and karaf should be used, just like when running openHAB in ‘production’. Watching bundles with bundle:watch * on the local maven repository seems to work really well, only the turn-around time after a change is really long IMHO, so I think it needs some tweaks to skip most/all steps of the test/check process.

I think most developers want to run a full openHAB development environment and also be able to edit & debug core, if only to better understand how openHAB works.

At the moment I am working on a IntelliJ development setup and intent to share my journey if am succesful…

If you develop a binding you don’t need to import core or any other binding. You can still debug on core as it’s available via the dependencies. If you do want to modify code in core you can import the specific core project you want to modify only.

There is a guideline on how to develop with intellij.dis you see that: IntelliJ | openHAB

Hi Rogier and Hilbrand,

Thanks for reaching out! I’ll give it a try with intelliJ.
@rogierhofboer, great to read about your experience in detail!

I understand core is not necessary to checkout, but I did so mainly to learn about the architecture.
I’ll keep persisting, and hope to share some code once :slight_smile:

BTW The reason the full Windows build of core fails is this issue:
Core tests: one test failing (ByteArrayFileCacheTest) · Issue #1846

@hilbrand I did see the guidelines, but except for Eclipse, they assume you only want to develop a binding. The Eclipse setup as described does not seem to work well, I’ve tried it on Linux and Windows and end up with a lot of errors.

Getting it to even compile with the mvn command line is very frustrating:

openhab-webui on Windows:
[INFO] — frontend-maven-plugin:1.9.0:npm (gulp build) @ org.openhab.ui.basic —
[INFO] Running ‘npm run build’ in C:\openhab-main\openhab-webui\bundles\org.openhab.ui.basic
[INFO]
[INFO] > org.openhab.ui.basic@3.0.0 build C:\openhab-main\openhab-webui\bundles\org.openhab.ui.basic
[INFO] > gulp default
[INFO]
[INFO] fs.js:35
[INFO] } = primordials;
[INFO] ^
[INFO]
[INFO] ReferenceError: primordials is not defined
[INFO] at fs.js:35:5
[INFO] at req_ (C:\openhab-main\openhab-webui\bundles\org.openhab.ui.basic\node_modules\natives\index.js:143:24)
[INFO] at Object.req [as require] (C:\openhab-main\openhab-webui\bundles\org.openhab.ui.basic\node_modules\natives\index.js:55:10)
[INFO] at Object. (C:\openhab-main\openhab-webui\bundles\org.openhab.ui.basic\node_modules\vinyl-fs\node_modules\graceful-fs\fs.js:1:37)
[INFO] at Module._compile (internal/modules/cjs/loader.js:1158:30)
[INFO] at Object.Module._extensions…js (internal/modules/cjs/loader.js:1178:10)
[INFO] at Module.load (internal/modules/cjs/loader.js:1002:32)
[INFO] at Function.Module._load (internal/modules/cjs/loader.js:901:14)
[INFO] at Module.require (internal/modules/cjs/loader.js:1044:19)
[INFO] at require (internal/modules/cjs/helpers.js:77:18)

And on Linux:

[INFO] > openhab@3.0.0 build-prod /home/rogierhofboer/Projects/openhab-main/git/openhab-webui/bundles/org.openhab.ui/web
[INFO] > cross-env NODE_ENV=production node ./build/build.js
[INFO]
[INFO] sh: 1: cross-env: not found
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! syscall spawn
[INFO] npm ERR! file sh
[INFO] npm ERR! errno ENOENT
[INFO] npm ERR! openhab@3.0.0 build-prod: cross-env NODE_ENV=production node ./build/build.js
[INFO] npm ERR! spawn ENOENT
[INFO] npm ERR!
[INFO] npm ERR! Failed at the openhab@3.0.0 build-prod script.
[INFO] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Strange thing is, I got some working builds from within IntelliJ a while ago (using Maven as main builder, not the IntelliJ builder, that does not work)

On Linux I think I know what causes the problem… I was using Maven 3.8.1 and this seems to break things I don’t know (yet) how to fix. Unfortunately mvnd is based on 3.8.1, so can’t be used to speed the build up.
Anyway going back to Maven 3.6.3 solved the Linux issue and mvn clean install just finished.

Then trying a new mvdn (Maven 3.8.1) build with : mvdn clean install, but the npm packages still installed via Maven 3.6.3 I get the primordials error on Linux as well.
Maybe that one is easy to fix, because I am not the only one if I have to trust on a quick search.

To be continued.

TLDR:

  • Use Linux, Windows seems not well supported
  • Use Maven 3.6.3, not 3.8.1

Update:

OK. this is really hard to sort out… And maybe I should have started a separate thread…

As far as I know now, the two errors above are not related to the OS or Maven version at all… :blush:

the primordials error happens the second time you do a mvn clean install on the openhab-webui repo. So that’s the reason the ci server has no problems.

The issue seems the same as Modified files after build cause subsequent build to fail · Issue #241 · openhab/openhab-webui (github.com) .

The only solid solution I’ve found is upgrading gulp to 4.x and adapt the gulpfile.js for basic ui.
I will make a pull request for that change.

The cross-dev error is more strange. I’ve now seen it twice once in Ubuntu 20.04 in WSL2 and in a fresh Ubuntu 20.04 on VirtualBox.

To get rid of the error I also installed nodejs and npm on the machine itself with:
sudo apt install nodejs npm

Then did a npm install --global cross-dev and then the other packages it complains about after that one-for-one, the next one was webpack… Now the strange thing is it finally compiles, but when I then remove the installed nodejs and npm and as far as I know remove all traces of it, it still works and keeps working…

For some reason before installation and removal of the local nodejs and npm, the devDependencies are not installed when NODE_ENV=production is set.

This issue gives some hints:
/bin/sh: cross-env: command not found · Issue #187 · kentcdodds/cross-env (github.com)

To be continued…