How to test bundles with dependencies with openhab-test-distro?

Dear everyone,

I am currently implementing some commands to list, add, delete and change the role of a user in the karaf console. To do so, I modify the UserConsoleCommandExtension class in the org.openhab.core.io.console bundle at the following location
org/openhab/core/io/console/internal/extension/UserConsoleCommandExtension.java

And also the class UserRegistryImpl (and his interface UserRegistry) in the bundle org.openhab.core located at
org/openhab/core/internal/auth/UserRegistryImpl.java

I will implement the unit tests later. To test the commands I already wrote, I use the openhab distro directory with intellij as explained in this post:

But I have some problems to test a bundle with a dependency. The org.openhab.core.io.console bundle has a dependency with the org.openhab.core bundle. To test my implementation as explained in the post linked above, I need to run the mvn clean install command for each bundle and put its respective jar file in the addons directory of the openhab-test-distro directory and then run it with start_debug.sh. When I do that it does not work because the bundle org.openhab.core.io.console doesn’t have the dependencies with the bundle org.openhab.core.

How can I test a bundle with some dependencies? When I do a mvn clean install for the whole openhab-core project, I cannot find the yar file created in the target directory. I see in the openhab-test-distro that we can put the yar file in the runtime directory instead of the addons directory but that doesn’t work either.

Here you have the two bundles added and the org.openhab.core bundle is waiting as the bundle already exists as you can see in the images below:
bundle_core

bundle_console

Instead of adding a bundle, anyone know how to replace a bundle in openhab-test-distro?

I hope the explanation is clear, please tell me if it is not.

Thank you for your help,

Nicolas Gennart.

Hey there,
the tutorial mainly focusses on the development & debugging of bindings (addons), but if I’m not mistaken you made changes to the core. Thus, there is no need to build any addon JAR and put it into the addons directory - you can completely skip steps 4 - 7.

Instead, you should do the following:

  • clone the OpenHAB Core project (I assume you already did that)
  • make your changes to the core classe (I assume you already did that)
  • use mvn clean & install to build the core artifacts to the local Maven repository
  • clone the OpenHAB Distro project - this is part of the 1. step in the tutorial
  • make sure the OH-core dependency in the Distro project is pulling the the SNAPSHOT version from the local Maven repository
    • this is the important part, therefore the project versions in both projects (core & distro) must match or you can explicitly set the ohc.version property. I recommend the former. If you just clone the latest main of both projects, they will both be 3.3.0-SNAPSHOT and you’re good to go.
  • build the Distro project (also part of the 1. step in the tutorial)
  • continue with steps 2 & 3 to unpack, start and debug the OH distro

If you list the bundles it should only report 1 Core bundle and 1 Console bundle and the version should have the timestamp of the (core) build at the end of the version number (in the format year-month-day-hour- and so on).

1 Like

Thank you for your answer.

Now I have the good version for the both project ( OpenHAB Core and OpenHAB Distro project).

But I don’t think my modification of the openhab-core project will be taken into account in the openhab-distro project because in your explanation I don’t add any yar file in the openhab-distro project, and if I add one it will create as before a new bundle and will not replace the bundle. My question is:
Do you know how to replace a bundle of the openhab-core project in the openhab-distro project to test my implementation localy before I will do a pull request ?

I don’t add anything in the openhab-distro so it is strange.

Can you still guide me ?

Thank you for your help,

Nicolas gennart.

Hi,

It is ok I have found how to change a bundle of the openhab-core.

It is explain in this post:

At the distribution of the extracted zip file (explained in step 2 of the post HowTo: Setup IntelliJ for binding development). I just need to clear the cache and change the jar files in the runtime directory (in my case in runtime/system/org/openhab/core/bundles/org.openhab.core and in /runtime/system/org/openhab/core/bundles/org.openhab.core.io.console).

Thank you,

Nicolas Gennart.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.