Need some help with setup to create new binding using maven/bnd

Hi @Misiu, did you install the latest (201903) version of Eclipse IDE? And also, without any of the repositories during install? Only import as existing Maven project afterwards?

As David said, the README in the Addons Github repository should get you going, at least to come to a setup without those compile/build errors.

Yes I’ve installed the latest version.
After launch I’ve created a new workspace then in Package Explorer I right click and choose Import.
I’ve picked up Maven->Existing Maven Projects and selected folder where I git openhab-demo.
After that I got this errors:


Then I’ve added org.openhab.binding.airquality binding (using the same steps as above).

I’ve added all the missing binding’s but I still have 3 errors:

Missing artifact org.openhab.bundles:org.openhab.binding.synopanalyzer:jar:2.5.0-SNAPSHOT

The container ‘Maven Dependencies’ references non existing library ‘C:\Users\Tomek.m2\repository\org\openhab\bundles\org.openhab.binding.synopanalyzer\2.5.0-SNAPSHOT\org.openhab.binding.synopanalyzer-2.5.0-SNAPSHOT.jar’

The project cannot be built until build path errors are resolved

I found that I miss one library:


but I don’t know how to fix that.

Video is on (I guess )official Youtube channel - https://www.youtube.com/channel/UC7OK88DW0La_BJlcXZg8ydQ/videos

I know it might not be best timing for this but you can do your binding alone without pulling in entire openhab. You need to pull in all necessary dependencies. Until addons are bnd-nized you can rely on simplistic maven approach. Take a look on below project - it has literally ONE line which set ups OSGi bundle activator.

If you want to have a proper binding create ESH-INF in your resources directory. OSGI-INF contents are generated by maven-bundle-plugin thus you just need to re-use existing annotations.

Most importantly - it works out of the box (with IntelliJ) and it should also work for other part of universe (Eclipse). Main drawback is - you need to install and update binding manually inside running openHAB instance via install file:/foo/bar/binding.jar and update <binding-id> or watch commands (you can find reference in Karaf manual).

Above way is less convenient than IDE driven development, but works quite reliability for most of people.

Cheers,
Łukasz

1 Like

Łukasz,
Binding (MCP23017) that I want to base my new binding on is already building on BND, so I’ll try with eclipse.
I’ll check Your suggestions tommorow, maybe it will be easier for me to get started.
The whole process of setting up everything is complicated. In Visual Studio it is simple - You click on csproj file and Your ready to go. This should be as easy with openhab :slight_smile:

P. S.
I’m running openHAB 2.4, will I be ae to add binding based on BND to it?

Yes, it’s gonna work. BND changes way how build is organized but does not change runtime. As long as output of compilation contains all necessary metadata it will pass.
If yo uused Visual Studio before then its worth to try IntelliJ anyway, sometimes its less verbose and seems to be easier for new comers. It is able to import most of maven projects. I’m not sure if it properly supports BND workspaces, but that’s something which is not required to work inside IDE to write your Java code.

I’m not so sure. I think @J-N-K has found out that a version restriction is currently compiled in (minimum OH 2.5-snapshot), but maybe he can elaborate more on this topic.

Ok, I have a clean PC.
Here are the steps I made:

  1. Install Eclipse for Java Developers
  2. Clone demo repo using git clone --depth=1 https://github.com/maggu2810/openhab-demo
  3. Import that project into Eclipse:
  4. Then the project start building
  5. And I got this:

What should I do next? Should I remove those missing dependencies? If yes, then how should I do that?

@David_Graeff, as You mentioned on GitHub a sample binding project that could be opened in VS Code, would be awesome!

I think the version was an earlier problem but that has been removed. I at least had no problem using newer versions on a 2.4

However, if the binding now gets the jar from maven dependencies, were it before had that jar in the lib directory. I think these need to be installed manually because that information is in the feature file.

Have you performed what I mentioned earlier about the “resolving” part?

Nevertheless, let’s ask @maggu2810. Can you have a look at the post from @Misiu above? Looks like the libraries that are in “lib” directories are not resolved.

I’ve tried all the possible thing I can think of.
I’ve imported project in different ways, I’ve tried Maven->Update Project, I’ve tried changing profiles using Maven->Select Maven Profiles.
I have my new binding almost ready (PCF8574 extender), but it is hard to test if if I can’t compile it :smiley:

Can you pleasae close the Eclipse IDE and run

mvn clean install -U

in the root of your working copy?

Please post the whole log.

Here is the full log, I wasn’t able to post it here, because it was too long.
openHAB_log.txt (138.6 KB)
there are couple of warnings while downloading dependencies and errors at the end:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for openHAB Demo 2.5.0-SNAPSHOT:
[INFO]
[INFO] openHAB Demo … SUCCESS [ 9.864 s]
[INFO] openHAB Demp :: App … FAILURE [02:38 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:48 min
[INFO] Finished at: 2019-04-03T14:45:54+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project org.openhab.demo.app: Could not resolve dependencies for project org.openhab.demo:org.openhab.demo.app:jar:2.5.0-SNAPSHOT: The following artifacts could not be resolved: org.openhab.addons.bundles:org.openhab.binding.allplay-tchaikovsky.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.allplay-tchaikovsky-sources.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.leapmotion-LeapJava.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.plclogo-Moka7-1.0.2_io_patch.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.rfxcom-jd2xx.jar:jar:2.5.0-SNAPSHOT, org.openhab.bundles:org.openhab.binding.synopanalyzer:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-netty-resolver-2.0.19.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-netty-all-4.0.42.Final.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-javatellstick-1.1.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-async-http-client-netty-utils-2.0.19.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-netty-resolver-dns-2.0.19.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-async-http-client-2.0.19.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-netty-reactive-streams-1.0.8.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-reactive-streams-1.0.0.jar:jar:2.5.0-SNAPSHOT: Could not find artifact org.openhab.addons.bundles:org.openhab.binding.allplay-tchaikovsky.jar:jar:2.5.0-SNAPSHOT in openhab-artifactory-snapshot (https://openhab.jfrog.io/openhab/libs-snapshot) -> [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] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :org.openhab.demo.app

Please remove the openhab-addons BOM stuff from your local Maven repo.

Delete the directory

.m2/repository/org/openhab/addons/bom/org.openhab.addons.bom.openhab-addons/2.5.0-SNAPSHOT

that is found relative to your user home.

After that try again.

I’ve done that, but that folder got created again when I called “mvn clean install -U”
This is its content:

again I got some warnings and errors at the end:

[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.allplay-tchaikovsky.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.allplay-tchaikovsky-sources.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.leapmotion-LeapJava.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.plclogo-Moka7-1.0.2_io_patch.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.rfxcom-jd2xx.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.bundles:org.openhab.binding.synopanalyzer:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.tellstick-netty-resolver-2.0.19.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.tellstick-javatellstick-1.1.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.tellstick-async-http-client-netty-utils-2.0.19.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.tellstick-netty-resolver-dns-2.0.19.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.tellstick-async-http-client-2.0.19.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.tellstick-netty-reactive-streams-1.0.8.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.openhab.addons.bundles:org.openhab.binding.tellstick-reactive-streams-1.0.0.jar:jar:2.5.0-SNAPSHOT is missing, no dependency information available

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for openHAB Demo 2.5.0-SNAPSHOT:
[INFO]
[INFO] openHAB Demo … SUCCESS [ 0.672 s]
[INFO] openHAB Demp :: App … FAILURE [02:27 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:28 min
[INFO] Finished at: 2019-04-03T15:12:50+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project org.openhab.demo.app: Could not resolve dependencies for project org.openhab.demo:org.openhab.demo.app:jar:2.5.0-SNAPSHOT: The following artifacts could not be resolved: org.openhab.addons.bundles:org.openhab.binding.allplay-tchaikovsky.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.allplay-tchaikovsky-sources.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.leapmotion-LeapJava.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.plclogo-Moka7-1.0.2_io_patch.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.rfxcom-jd2xx.jar:jar:2.5.0-SNAPSHOT, org.openhab.bundles:org.openhab.binding.synopanalyzer:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-netty-resolver-2.0.19.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-netty-all-4.0.42.Final.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-javatellstick-1.1.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-async-http-client-netty-utils-2.0.19.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-netty-resolver-dns-2.0.19.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-async-http-client-2.0.19.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-netty-reactive-streams-1.0.8.jar:jar:2.5.0-SNAPSHOT, org.openhab.addons.bundles:org.openhab.binding.tellstick-reactive-streams-1.0.0.jar:jar:2.5.0-SNAPSHOT: Could not find artifact org.openhab.addons.bundles:org.openhab.binding.allplay-tchaikovsky.jar:jar:2.5.0-SNAPSHOT in openhab-artifactory-snapshot (https://openhab.jfrog.io/openhab/libs-snapshot) -> [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] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :org.openhab.demo.app

There is a BOM that references that bundles.
The intention of the removal has been that the BOM is taken from the snapshot repository and no local build is used (so the most recent of https://openhab.jfrog.io/openhab/libs-snapshot/org/openhab/addons/bom/org.openhab.addons.bom.openhab-addons/2.5.0-SNAPSHOT/)
If the BOM is taken from the repository also the dependencies defined in the POM should be available in the repository.

The first missing one is

  • groupId: org.openhab.addons.bundles
  • artifactId: org.openhab.binding.allplay-tchaikovsky.jar

The dependency is declared here: https://openhab.jfrog.io/openhab/libs-snapshot/org/openhab/addons/bundles/org.openhab.binding.allplay/2.5.0-SNAPSHOT/org.openhab.binding.allplay-2.5.0-20190331.091233-6.pom

The files are not found in a Maven repository.

The JAR file itself are not found in a Maven repository.
They are pushed to the local repository while building the respective addon.

As already stated, this is a bad idea.
Your error is an example why we should not use such dependencies (it is similar as using the system scope).

is there a way I or someone can fix this? Maybe there is a workaround?
Should I clone addons and build those that are missing?

It should be fixed by the addons by moving to Maven coordinates for its dependencies.

What you can do as a workaround is to add an exclusions element for the addons bom dependency of the demo that contains an exclude section for every artifact that you listed above.

Unfortunately that will not happen for the mentioned ones. Most jars have been eliminated, but the listed ones are not going in the near future because lack of time :frowning:

A working demo repo for all the other working bundles would still be welcome.

Hm, shouldn’t this one https://github.com/openhab/openhab2-addons/pull/5385 already fix the dependency chain?

1 Like