Develop or update an addon and add it to the openHAB 2.4 stable release - what approach makes sense?

Dear Community,

I need to develop / change a binding for the openHAB 2.4 build. How can I do that? It is no option to wait for a stable 2.5 snapshot in a few weeks.

I see three options:

  1. I get an Eclipse IDE which installs the 2.4 snaphot out of the box and I am creating the binding from scratch and create the jar and afterwards put the jar file into the addon folder
  2. I put my binding source files into a folder and try to run the maven build outside of any openhab-eclipse environment. I guess I need to edit some pom files before having some success on this approach.
  3. I install the current Eclipse IDE with the 2.5 snapshot and then I add my binding and run the maven build. I put the created snapshot 2.5 binding jar file into my 2.4 openhab snapshot and all runs smoothly?

Thanks in advance for your feedback.

Best regards,
Jochen

That works yes

1 Like

IMHO 1 and 3 are the same.
When installing an IDE now you will get the snapshot version, which is actually 2.5
Coding and creating it with mvn will do the job and you can use that .jar by putting it into the add-ons folder.
BTW: If waiting a “few weeks” is no option, how fast do you think you can code a binding? If you are that fast, you could help out the community by working on some reported issues. WDYT?

Yes, I will try to contribute, to the addons and the core! By the way: it is not a binding to get a new home automation stack to openHAB, so the challenge won’t be that big I hope.

Writing a small binding for a REST service for example only takes an hour @opus.
What takes time is the documentation, commenting the code etc.

New bindings should be written with the new buildsystem btw. They go into the “bundles” directory instead of the “addons” directory.

1 Like

OK - thanks for your answers so far.

I tried to check the approach by setting up a fresh IDE and and then running m2eclipse with the goals “clean install” on an existing binding as an example - here the “feed”-binding. The binding is not changed, it works fine in die 2.4 stable release and there is no error shown after performing all setup tasks. I was expecting, that the build will run smoothly and there will be a jar file related to the 2.5 snapshot. Instead I got this error:

[INFO] — maven-resources-plugin:3.1.0:copy-resources (default) @ org.openhab.binding.feed —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] — target-platform-configuration:1.2.0:target-platform (default-target-platform) @ org.openhab.binding.feed —
[INFO]
[INFO] — tycho-packaging-plugin:1.2.0:package-plugin (default-package-plugin) @ org.openhab.binding.feed —
[INFO] Building jar: E:\joba\workspace-openhab\OpenHabAddonDev\openhab-master\git\openhab2-addons\addons\binding\org.openhab.binding.feed\target\org.openhab.binding.feed-2.5.0-SNAPSHOT.jar
[INFO]
[INFO] — tycho-p2-plugin:1.2.0:p2-metadata-default (default-p2-metadata-default) @ org.openhab.binding.feed —
[INFO]
[INFO] — sat-plugin:0.5.0:checkstyle (default) @ org.openhab.binding.feed —
[INFO] Adding dependency to checkstyle:0.5.0
[INFO] Adding dependency to checkstyle:8.1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:25 min
[INFO] Finished at: 2019-03-12T21:01:52+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openhab.tools.sat:sat-plugin:0.5.0:checkstyle (default) on project org.openhab.binding.feed: Unable to execute mojo: An error has occurred in Checkstyle report generation. Failed during checkstyle execution: Unable to find suppressions file at location: E:\joba\workspace-openhab\OpenHabAddonDev\openhab-master\git\openhab2-addons\addons\tools\checkstyle_suppressions.xml: Could not find resource ‘E:\joba\workspace-openhab\OpenHabAddonDev\openhab-master\git\openhab2-addons\addons\tools\checkstyle_suppressions.xml’. → [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] MojoExecutionException - Apache Maven - Apache Software Foundation

This is a known problem. Until the issue is resolved, you can add this option to your command to build the binding: -DskipChecks=true

For example

mvn -DskipChecks=true clean install

Thanks for your reply. Anyway it did not solve the issue.

I was running m2eclipse with clean install and the “Skip Tests” option. Same error - now I try to start the build on the main pom file, not on the feed package one’s.

OK,

now I created a Run Configuration and went into the poms/tycho folder to pick the pom to run. Then I set the goals “clean install” and the flag for “Skip Tests”. Now the build failed, but I was able to run successfully through some bindings and so there was a jar file in the target folder!

Now I am curious if the other bundles will get built when I create a run configuration for the pom in the bnd-folder. When I exclude all other bindings besides this one I want to build, then the procedure shouldn’t take that much time.

Any more advice from your side?

Thanks Mark,

it was possible to get a successful build with your line of code. What do I need to do exactly in Eclipse m2eclipse, because there was no successful build, altough I thought that my command will do the same?

just run the following inside your binding folder and then it only builds just your binding. Also if you need to run it often, you can run with -o for offline mode and it builds so much faster as it does not download everything from scratch.

mvn clean install

Only if you are going to do a PR to merge your binding into Openhabs github do you need to run it across all bindings.

FYI. There’s a PR to fix the checkstyle_suppressions.xml issue, but it hasn’t been merged yet.

@Jochen_Bauer The PR was just merged, so maybe try rebasing your branch to see if that resolves the issue.

Hi Jochen, did you managed to create/edit binding? I’m new to ECLIPSE, could you write down step by step or point to link, what needs to be installed and which options chosen and how to load an existing binding from repo, and how to create jar file?
I need to change one binding to suit my needs, unfortunatelly creator of that binding is no help, so I have to DIM

thanks

You should have started a new thread on such topic!

I used this documentation in order to setup Visual Studio Code and was able to run the binding code in debugging mode (breakpoints useable and so on
) and push the changes for a PullRequest. Why don’t you try the same steps?

thanks I will try.