I tried to build the Shelly Binding based on the current repo (OH5), which fails
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project org.openhab.binding.tradfri: Compilation failure: Compilation failure:
[ERROR] /Users/markus/Dev/openhab-5/git/openhab-addons/bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriGatewayHandler.java:[33,8] The import org.eclipse.californium.scandium.config.DtlsConfig cannot be resolved
[ERROR] /Users/markus/Dev/openhab-5/git/openhab-addons/bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriGatewayHandler.java:[76,9] DtlsConfig cannot be resolved
[ERROR] /Users/markus/Dev/openhab-5/git/openhab-addons/bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriGatewayHandler.java:[162,17] org.eclipse.californium.elements.config cannot be resolved
[ERROR] /Users/markus/Dev/openhab-5/git/openhab-addons/bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriGatewayHandler.java:[163,30] DtlsConfig cannot be resolved to a variable
[ERROR] /Users/markus/Dev/openhab-5/git/openhab-addons/bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriGatewayHandler.java:[164,30] DtlsConfig cannot be resolved to a variable
[ERROR] /Users/markus/Dev/openhab-5/git/openhab-addons/bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriGatewayHandler.java:[194,21] org.eclipse.californium.elements.config cannot be resolved
Have the Californium components been removed from default dependencies?
feature.xml includes
Cannot find the declaration of element âprojectâ,
which could be fixed by ticking
Preference â Maven â tick the option (âdownload artifact javadocâ)
File:Import:Existing Maven Project:Shelly binding
Maven->Update project
Still same issue (import Californium failed)
I See
âââ
Conflicting lifecycle mapping (plugin execution biz.aQute.bnd:bnd-maven-plugin:7.1.0:bnd-process (execution: default, phase: process-classes)): Mapping defined in âbndtools.m2e_7.1.0.202411251545 [18]â and âorg.eclipse.m2e.pde.connector_2.2.0.20241001-1350 [380]â. To enable full functionality, remove the conflicting mapping and run Maven->Update Project Configuration.|pom.xml|/org.openhab.binding.shelly|line 7|Maven Project Build Lifecycle Mapping Problem
âââ
in the build errors.
Hello Markus,
I am sorry to see your struggle. Since you started to get compilation issue straight from maven, it is important to confirm if same issue occurs in CI/CD pipeline. If not then it is environment specific and we can look for differences causing these.
The openHAB 5 branch is Java 21, but 4.x should be still fine with Java 17. What may be different is californium version used in OH 4.x and 5. This will impact directly bindings which rely on dependencies provided by OH transport.
Also, if you are building everything locally - make sure you have also a fresh build of OH core for given version. Sometimes snapshots are getting stale and mixed all together (local maven repo vs remote repos), leading to inconsistent output from the build.
Finally - if you will push your changes somewhere, I could try to reproduce it and help you with the fix.
I always build bindings from command line using i.e. mvn package -pl :org.openhab.binding.shelly (if I need it), so if any other bindings fail, I can simply ignore error and still get binding I need.
The main thing to note, because californium got a major update you most likely wonât get exactly same code working with OH 4.x and 5.x. You can still try to cherry-pick changes between branches for places which rely on OH or Californium API which remained same between californium 2.7 and 4.x. So while you may cherry-pick changes between OH branches, the build needs to follow types available there, and you wonât be able to build from single branch 2 versions targeting different runtime.
I built tradfri binding from 4.3.x and main branch (5.0.0-SNAPSHOT) without any issues, with one note - I used command line.
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk/
cd openhab-core
git checkout 4.3.x
mvn clean install
cd openhab-addons
git checkout 4.3.x
mvn clean install
For openhab 5.0.x
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk/
cd openhab-core
git checkout main
mvn clean install
cd openhab-addons
git checkout main
mvn clean install
So I did not try to compile main branch with Java 17 yet.
thatâs a good approach to keep those changes within the corresponding code base and make sure to have the 100% OH4 environment.
However, I need Eclipse for debugging
and the OH4 setup shows the same problem
Fresh IDE install based on OH5
Switch openhab-addons and openhab-bistro to 4.3.x branch
need to change from 4.3.1-SNAPSHOT to 4.3.5-SNAPSHOT in pom.xml of the demo app (a glitch, but could be handled)
Start Eclipse â all good so far
import binding
Maven:Update project
Eclipse shows the lifecycle problem + unable to resolve dependencies (see above)
How do you do your debugging?
So far, I couldnât fine a proper setup with OH5 or OH4 environment to get back to development. Maybe itâs related to macOS, I think I tried all other aspects (different Eclipse releases, different binding, deleted .m2/.p2/.bnd/.eclipse folder, 2nd machine, main branch + my fork)
Any other idea?
Could you please try a fresh IDE install so we know if
a) works for you incl. Eclipse
b) is related to macOS or not
c) my machine/personal setup
Many thanks for getting into this, looking forward to the break-through
Iâm reluctant to test this myself since compiling OHC takes some time, but as long as youâre using all 4.3.x branches (for core, distrib, addons, webui etc.) it should work. What Iâve found is that when switching to a different commit, you need to rebuild everything that has changed in projects that arenât open in Eclipse, using Maven from the command line. So, when switching between 5.x and 4.x, it basically means to rebuild everything.
The quickest way of doing that is to run, from the repository root:
This will install artifacts in your local maven repo (home/.m2) of the given version, so that when Maven tries to resolve dependencies, it will find them.
I always do that before even attempting Maven â Update project.
I will add that since rebuilding everything is quite time-consuming, I think a better approach might be to have multiple git repo clones locally, e.g âcore 5.xâ and âcore 4.xâ. You can import additional projects in Eclipse using Import â Existing Maven Project. You can specify which JDK to use on a per-project basis in Eclipse, so you could permanently assign JDK17 to the â4.x branchesâ. Again, this is untested, but I think it should work as long as you donât open both the â4.xâ and â5.xâ version of the same project in Eclipse simultaneously.
When it comes to building OH5.x using -P17 I donât understand how that could work. People eager to prevent backwards compatibility have done various updates to the code to use Java21 specific syntax, so the current âmainâ code canât compile with Java17.
yep, having separate OH4 and OH5 clones is the way Iâll go. This will fix the Californium problem, because the new version requires changes to 1 code file.
However, Iâm still struggling to do a build/debug in Eclipse, even in the OH4 folder.
Whatever I try I see an error in the bindingâs pom.xml
Conflicting lifecycle mapping (plugin execution "biz.aQute.bnd:bnd-maven-plugin:7.1.0:bnd-process (execution: default, phase: process-classes)"): Mapping defined in 'bndtools.m2e_7.1.0.202411251545 [18]' and 'org.eclipse.m2e.pde.connector_2.2.0.20241001-1350 [380]'. To enable full functionality, remove the conflicting mapping and run Maven->Update Project Configuration. pom.xml /org.openhab.binding.shelly line 7 Maven Project Build Lifecycle Mapping Problem
I even tried a 2nd machine, which never had an Eclipse/OH installation.