Compiling oh3 thing

Dear experts,

I am trying to refactor the volumio2 thing written by Patrick Sernetz into an OH3 binding/thing.
However, after many hours of breaking my head around this I am asking for some help.

My starting point was the OH3 demo app (after installing eclipse /Java 11 with all instructions), from which I’ve added the classes/xml for the volumio2 thing. I’ve followed the developer guide on things, and most items overlap from OH2, yet slightly different (e.g. ESH → OH in imports).

Now, I keep running into a ‘dead end’ since I an error in the pom.xml on the 'execution tag of the bnd-proces / bnd-maven-plugin. Furthermore, I get errors all over the place regarding missing declarations (e.g. “org.openhab.core cannot be resolved” although the initial demo app had everything aligned correctly. I also played around with the build path and other dependencies without luck. A final error I get concerns the pom “default package . is not permitted by the Import-Syntax package” ( which I think has to do with the order of the build path).

Could anyone enlighten me? Thank you very much!

PS: my programming experience is good enough yet java is quite rusty… the complexity of these java projects don’t stick to my mind.

Jan-Bernard

Sorry to read that. I cannot help you with this issue, but share my experience working on two bindings since ‘years’. I also never managed to understand what is going on in the build process and espiecially the “bnd resolve” regularly fails for me without a clue why. Usually I try then to restart from scratch, sometimes I forgot to put my binding into to pom.xml of the demo app and often I have to try random things without understanding what is going on and afterwards normally to being able to explain what I did. Often I waste hours with the infrastructure for changing a few lines of code.

Don’t want to discourage you, but yes, maybe there is some potential to improve the build system or the docs to simplify the development, especially for newcomers.

I usually run a full openHAB in debug Mode only my development machine (without configuration) and connect from my IDE to that via remote debugging. The new bundles are deployed by dropping them in the addons folder. In most cases you can just overwrite the old bundle with the new bundle and it get‘s replaced. If something goes entirely wrong (like tasks still running), just delete the jar and restart the openHAB instance. Works perfectly fine without using bnd to resolve the bundle.

I was getting that a week or 2 back and I put it down to some changes to the build system. It may have been a syntax error on my end in the OSGI tags at the start of the classes, I forget… Try doing this…

  1. BACKUP your work so you have the code you have already written safely backed up.
  2. Rebase the binding with latest changes made to openhab/addons. See below for how.
  3. Right hand click on your binding in the list of projects if using Eclipse IDE, then select MAVEN>UPDATE PROJECT. The shortcut ALT+F5 may do the same thing.

Here are the commands for rebasing your branch:

Backup your work FIRST, always backup.
If not already done, add the upstream openHAB addon repo as a remote to your local repo and fetch it:

git remote add upstream https://github.com/openhab/openhab-addons.git
git fetch upstream
Then, you can rebase your PR’s branch onto main:
git rebase upstream/main

If that fails, check why with this and it usually makes some suggested ways forward:
git status

Finally when there are no issues, force-push the rebased branch to your own branch:

git push origin [your branch name] --force-with-lease

Be careful of doing a force-with-lease if multiple people are working on the project. If your the only one, then just be aware this can not be reversed like a normal git opperation so backup your work before starting all of this.

Hi everyone,

Thanks all for your quick replies! So far no luck yet,
but with your suggestions I keep learning to understand the build process
bit by bit. For now, I resolved some errors through new checkout/build
Yet everytime I import the existing code, it cannot resolve the core stuff.
In the meantime, I’ll do a cry for help in the volumio thread who has succesfully
compiled the plugin for OH3 :slight_smile: and share the jar file.

When I manage compiling on my own, I will update this thread.

Jan-Bernard

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.