Help for beginners (development)

I strictly followed the wiki page: IDE Setup · openhab/openhab1-addons Wiki · GitHub
and I was able to build openHAB and run it on my Windows 7 PC. 8)

A probable stupid question: my Git clone from GitHub - openhab/openhab1-addons: Add-ons for openHAB 1.x gives me what version ? The up-to-date version with all the last commits ?

Then in Eclipse I exported the mios project to a jar file (I used the default options in Eclipse UI). Then I copied this new jar in my RPI naming the file something like org.openhab.binding.mios-1.7.0-lolodomo.jar. Finally I started openHAB. Mios binding seems to be run (I see traces relative to my Vera devices). Unfortunately, the Mios binding is no more working well (light switch not working).
So what’s wrong and what the proper way to build a new JAR file for a binding ?

To produce a binary zip yourself from your code, you can simply call mvn clean install from the repository root and you will find the results in the folder distribution/target (you will of course need a Maven 3.0 installation as a prerequisite).

Do I have to use Maven ? Is Maven already installed and setup in Eclipse (Yoxos packaging) ? How to run a Maven command line with a Windows PC ? Through a terminal window ?

[quote=“lolodomo, post:1, topic:186724”]I strictly followed the wiki page: IDE Setup · openhab/openhab1-addons Wiki · GitHub
and I was able to build openHAB and run it on my Windows 7 PC. 8)[/quote]

Congrats, that can be a significant step on it’s own (seriously, I’m not joking)

A probable stupid question: my Git clone from https://github.com/openhab/openhab gives me what version ? The up-to-date version with all the last commits ?

It’s a 1.7 SNAPSHOT rev. Your commits always go first to your clone’s working-branch, but “openhab/openhab” is presently representing the latest, or 1.7.0. When you commit, submit a PR and have it approved, that’s where it’ll be pulled into. If they need your changes in another of their branches, they’ll [mostly] pull/merge your PR.

Anyhow, you’ll have everything that’s gone through PR and been approved if you use their openhab/openhab line (no branch)

As always, once you clone, create a branch-off-that-clone for each thing you work on. It’s fairly easy to get yourself in a mess otherwise, esp once you need to work on multiple “unrelated” things concurrently (and, for PR’s, it’s best to keep changes small and localized)

Then in Eclipse I exported the mios project to a jar file (I used the default options in Eclipse UI). Then I copied this new jar in my RPI naming the file something like org.openhab.binding.mios-1.7.0-lolodomo.jar. Finally I started openHAB. Mios binding seems to be run (I see traces relative to my Vera devices). Unfortunately, the Mios binding is no more working well (light switch not working). So what's wrong and what the proper way to build a new JAR file for a binding ?

I’m still building from the CLI, directly with mvn. I use Eclipse only as a fancy editor for search/replace refactor and a few other things that operate at that layer. When using mvn, I just build my Binding’s target (most of the time) to keep the overall process fast. I’ll only rebuild from root if I do a major refresh (which is uncommon)

When building with the CLI, you’ll have the Binding’s “target” directory. In this directory is the built product. In the case of MiOS, it’ll [currently] be [tt]org.openhab.binding.mios-1.7.0-SNAPSHOT.jar[/tt].

Really, it can be any name when you copy it to your Addons folder, but make sure that you’re not running “two” of the same functionality (eg a-mios-x.jar and a-mios-y.jar) since BOTH will be started by the OSGi Container. Don’t even keep them “renamed” in the same folder, or in a Sub-folder, as bad things happen (even without the .jar extension)

To produce a binary zip yourself from your code, you can simply call mvn clean install from the repository root and you will find the results in the folder distribution/target (you will of course need a Maven 3.0 installation as a prerequisite).

Do I have to use Maven ? Is Maven already installed and setup in Eclipse (Yoxos packaging) ? How to run a Maven command line with a Windows PC ? Through a terminal window ?

Kinda. It’s co-ordinating the build, and there are a bunch of items that “depend” upon it in that overall process. At this stage, I can’t imagine not using mvn to do this, since the rework would be extensive.

PS: That Yoxos thing is going to have to change, no idea what that change will actually look like, but they made some announcements about the Yoxos repo recently.

I will rebuild my env for OSH2, and will likely build a VirtualBox to run that, then I’ll have a “host-neutral” install option, which will be handy for a few different things… least of which is a better install (hopefully)

That was probably too easy yesterday ::slight_smile:

Today, I installed Maven v3.3.1 and add variable JAVA_HOME as new user variable and add the new Maven path in my PATH variable.

I don’t know if it is the origin of my problem but when I opened Eclipse, I saw several projects with compile errors. Then I run a full clean and now almost all projects have compile errors !
Several errors are relative to not using source level v1.5 or greater. In my preferences, Java compiler compliance level is still set to 1.7 like yesterday.

Any idea ?

A conflict between new installed Maven3 and the Maven embedded in Eclipse ?

No idea, but for this type of openHAB specific info it’s best to ask on the openHAB Google Group itself. There are many more folks over there to answer this and, so far, I’ve not been successful at working/compiling in the IDE (just from mvn command line, version 3.0.5 in my case)

When I open project properties of any project, I see that I am not using project specific settings and I see, in greyed, source compatibility set to 1.3 and compiler compliance level set to 1.4.
It looks like the projects are not inheriting right properties from the workspace.

My problem is probably not relative to openHAB but a basic Eclipse setting that I missed !
Why was it ok yesterday and not today, that is a mystery.

Problem solved. I switched compiler compliance level from 1.7 to 1.6. Rebuild was OK. Finally I switched it again to 1.7; reload was OK !
Now when I open any project properties, I see 1.7 everywhere as I was expected.

I just loosed 2 hours :o

Ok, I was able to use Maven to build everything (“mvn clean install” when at openhab root) or just one particular binding (mvn clean package when inside the binding). I tried successfully to deploy an updated (message log added) binding JAR file to my RPI server. OH still working well with the updated binding. That’s really a good start point. 8)

Last thing to do was to have a similar OH server that I could start within Eclipse. So I tried to duplicate my RPI OH setup (sitemap, items, rules, …) into my Windows development environment, putting files in openHAB\distribution\openhabhome. Of course, I copied required JAR files into openHAB\distribution\openhabhome\addons. When I start the server from Eclipse, the server is started and I can see that it has loaded my sitemap and items. But it looks like most of my bindings (maybe noone) are not loaded. Any idea ?

Then I will have a lot to learn about Git, Maven, … and of course how to implement a binding.

That looks better to not change the Git working directory for that. In fact, I finally changed the working directory in the “Run configuration” window in Eclipse. Currently, I use a network share that points to my RPI openHAB home directory (my production environment). When needed, I will create a separate directory structure locally in the PC.

Of course, I copied required JAR files into openHAB\distribution\openhabhome\addons. When I start the server from Eclipse, the server is started and I can see that it has loaded my sitemap and items. But it looks like most of my bindings (maybe noone) are not loaded. Any idea ?

For beginners like me, you must not copy JAR files in the addons subdirectory (like you do in a user environment) but just select the binding to launch at startup in the “Plug-ins” tab of the “run configuration” window in Eclipse (set auto startup to “true”).

Ok, now server started from within Eclipse looks good too. My development environment is working, YES 8)

@guessed: when starting server from within Eclipse, I get errors of this kind for most of my Mios items:

13:33:13.374 [WARN ] [transform.TransformationHelper:38 ] - Cannot get service reference for transformation service of type MAP 13:33:13.374 [WARN ] [b.m.i.config.MiosBindingConfig:284 ] - Transformation Service (in) 'MAP' not found for declaration 'MAP(miosSwitchIn.map)'. 13:33:13.374 [DEBUG] [b.m.i.config.MiosBindingConfig:368 ] - Couldn't create state of type 'class org.openhab.core.library.items.SwitchItem' for value '0'

Do I have to place additional map files in a particular place in this case ?

Answer to myself: strangely, the transform files have to placed into grit\distribution\openhabhome\configurations\transform