Openhab-core + maven/bnd addon

(David Graeff) #1

Hey developer community,

I’m feeling a bit lost with maven/bnd on eclipse/bndtools. The tutorial on is unfortunately outdated.

I like to archive the following:

  1. Having openhab-core in my eclipse workspace, as well as a maven/bnd project: Works
  2. Start a bndrun file (for example the demo one), and add my maven/bnd project bundle or any other eclipse workspace maven/bnd project bundles to it: No idea

I know how to handle this with Gradle and eclipse/buildship, but in that case the bndrun file is generated. So how do I go forward with an existing bndrun file?

What I have done so far in eclipse

  • Right click on my maven/bnd project and add the bnd nature (in this case for demo purposes the astro binding)
  • Modify the demo bndrun file:
-runrequires: \

-runbundles: \

Resolving the bndrun file fails with org.hamcrest not available. But I have probably not done it in the correct eclipse/bndtools way I guess.

Cheers, David

(Scott Rushworth) #2

David, have you tried adding it through the console?

(David Graeff) #3

I can probably just add the jar file to the runtime directory and karaf will resolve and load it. But that doesn’t help with debugging does it? And it doesn’t auto-reload the bundle on changes within eclipse without that additional copy file step.

(Scott Rushworth) #4

No, this won’t help with debugging, but you hadn’t mentioned that was a requirement :slightly_smiling_face:. The IDE is not using Karaf, so it will be slightly different than what you are used to. I’ve added bundles directly from the target directories… never copied to runtime.

(Jan N. Klug) #5

Did you look at This gives me at least a running OH in Eclipse, I didn’t manage to add my own bundles, but only looked at it for a minute or so. Maybe that is a point to start with.

(David Graeff) #6

Thanks for the link. The original openhab-core repo works since a few days though. You can start and debug core bundles from within the ide.

But I have not the slightest idea on how to add another bundle to the bnd workspace which to my understanding is a prerequisite to add it to the bndrun file. @maggu2810, do you have a helping link or a few minutes?


(maggu2810) #7

We are not using the Bnd workspace or Bnd natures.
We are using Maven + Bnd.
I assume the tutorial
So, do not add the the Bnd nature.

If you would like to learn more about it try to read the enRoute tutorials and documentation.

IIRC I read in this community that tests are not working inside the IDE or debugging is not working.
This is not correct!
Perhaps it does not that way the people think it should work. :wink:

So, let’s assume you are using openHAB Core and my openhab-demo branch (imported in the IDE) – what are you missing?

You can open the POM of my demo app (openhab-demo) and add further dependencies.
This dependencies should then be part of bundles you can add.
After all is done you need to resolve the app and you can start and debug it.

The resolving itself will not work as intendet as long as the DS requirements are disabled.
So, you should perhaps always cherry-pick

(David Graeff) #8

Ah ok. Now I understood. I’m not using any of the bnd UI stuff (except the resolve button maybe) in eclipse.

I’m using plain maven dependencies, like with gradle and bnd resolve will find those bundles.

Is the eclipse maven combo smart enough to find dependencies in my eclipse workspace instead of online resolving them?

I forgot to mention that, I did apply that change of course

(maggu2810) #9

AFAIK with 4.2 (perhaps 4.1, too) if a Maven coordinate is part of your workspace, that one will be used.
But you need to check it yourself.

(David Graeff) #10

Works. The workspace bundle is preferred.

For new contributors it need to be easier or better documented of course.

But I guess as soon as we have converted all openhab2-addon projects and the distro, we have a demo bndrun file that can resolve all those addon bundles and the new contributor can basically drag&drop within the bnd UI eclipse interface.

Cheers, David