[SOLVED] Building my first binding in Eclipse

Hi all,
After reading through a lot of posts here, it looks like there has been a lot of recent work on making it easy to develop a binding.

I followed the Eclipse guide (v2.5) to a tee. I’ve even been able to debug existing bindings! I created a new binding using the create_openhab_binding_skeleton script and built it using mvn. But I can’t debug using the org.openhab.demo.app app.bndrun system.

The problem I’m hitting is the demo app can’t find the dependency. I’ve added the dependancy to the demo app pom.xml, but it looks like Maven is trying to download my new binding from a external repository (which it’s obviously not in yet). How do I tell the demo app to use the locally built version rather than trying to download it?

I’m presumably missing something silly. I think what I’m trying to do is exactly what the development guide is tailored to (creating a new binding).

The full error is as follows

Failed to execute goal on project e[36morg.openhab.demo.appe[m: e[1;31mCould not resolve dependencies for project org.openhab.demo:org.openhab.demo.app:jar:2.5.1-SNAPSHOT: Failure to find org.openhab.addons.bundles:org.openhab.binding.zabbix:jar:2.5.1-SNAPSHOT in https://openhab.jfrog.io/openhab/libs-snapshot was cached in the local repository, resolution will not be reattempted until the update interval of openhab-artifactory-snapshot has elapsed or updates are forcede[m (biz.aQute.bnd:bnd-maven-plugin:4.3.0:bnd-process:default:process-classes)

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project e[36morg.openhab.demo.appe[m: e[1;31mCould not resolve dependencies for project org.openhab.demo:org.openhab.demo.app:jar:2.5.1-SNAPSHOT: Failure to find org.openhab.addons.bundles:org.openhab.binding.zabbix:jar:2.5.1-SNAPSHOT in https://openhab.jfrog.io/openhab/libs-snapshot was cached in the local repository, resolution will not be reattempted until the update interval of openhab-artifactory-snapshot has elapsed or updates are forcede[m
	at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:269)
	at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:147)
	at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:248)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:333)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.lambda$8(MavenImpl.java:1381)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:114)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1380)
	at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:54)
	at bndtools.m2e.BndConfigurator$1.build(BndConfigurator.java:130)
	at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:135)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:169)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$1(MavenBuilder.java:114)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:114)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$0(MavenBuilder.java:105)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:153)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:101)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:88)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:197)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:833)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:220)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:263)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:316)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:319)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:371)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:392)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project org.openhab.demo:org.openhab.demo.app:jar:2.5.1-SNAPSHOT: Failure to find org.openhab.addons.bundles:org.openhab.binding.zabbix:jar:2.5.1-SNAPSHOT in https://openhab.jfrog.io/openhab/libs-snapshot was cached in the local repository, resolution will not be reattempted until the update interval of openhab-artifactory-snapshot has elapsed or updates are forced
	at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:209)
	at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:243)
	... 33 more
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Failure to find org.openhab.addons.bundles:org.openhab.binding.zabbix:jar:2.5.1-SNAPSHOT in https://openhab.jfrog.io/openhab/libs-snapshot was cached in the local repository, resolution will not be reattempted until the update interval of openhab-artifactory-snapshot has elapsed or updates are forced
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:357)
	at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:202)
	... 34 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Failure to find org.openhab.addons.bundles:org.openhab.binding.zabbix:jar:2.5.1-SNAPSHOT in https://openhab.jfrog.io/openhab/libs-snapshot was cached in the local repository, resolution will not be reattempted until the update interval of openhab-artifactory-snapshot has elapsed or updates are forced
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:424)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229)
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:340)
	... 35 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find org.openhab.addons.bundles:org.openhab.binding.zabbix:jar:2.5.1-SNAPSHOT in https://openhab.jfrog.io/openhab/libs-snapshot was cached in the local repository, resolution will not be reattempted until the update interval of openhab-artifactory-snapshot has elapsed or updates are forced
	at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:218)
	at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:193)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:559)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:483)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:401)
	... 37 more

What is the version of the demo pom.xml and what is the version of your binding? If you use project.version in the demo pom.xml for your binding, it should be the same as the demo pom.xml otherwise use the specific version of your binding.

Using project.version for both. I also tried setting the version to 1.0.0 in both, but same error.

Not your binding, but the demo pom.xml version. If you use project.version it will look for your binding with that version number.

1 Like

You got it. Sorry, I jumped in for a fast reply without properly checking earlier.

The demo pom.xml version was 2.5.1-SNAPSHOT. My new binding was 2.5.2-SNAPSHOT (as were the other successfully built/linked bindings). I changed the demo pom.xml to 2.5.2-SNAPSHOT, cleaned, built and it works!

As I’m learning the OpenHAB build system, what would you suggest I do to solve these sorts of errors myself? I presume maven somehow deploys the bindings to a local repository after building, which the demo app then uses. Can I get my hands into the config which does this somewhere?

Happy to say, this was the only major hiccup I had after following the development guide (as precisely as I could, took me a couple of days and re-tries to get right though). The only other suggestion I would make to the docs is a section on forking and branching the main openhab-addons repo, instead of the default which clones the main openhab-addons repo.

Now, time to get coding. Hopefully a Zabbix binding will be helpful.

Very helpful, indeed! Would be very interested in testing it out when you get something working.