Import between my bundles cannot be resolved

Hello,

I’m trying out developing some bundles (not bindings) for openhab 2.5.0, and i cannot seem to find how to resolve imports between the 2 bundles i created.

What i did:

  1. Setup eclipse with bndtools and openhab
  2. Downloaded openhab2-addons package
  3. Imported openhab2-addons into eclipse
  4. Created project “org.openhab.homematic.tracker”
  5. Created a pom.xml for this project:

....
<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>org.openhab.addons.bundles</groupId>
		<artifactId>org.openhab.addons.reactor.bundles</artifactId>
		<version>2.5.0-SNAPSHOT</version>
	</parent>

	<artifactId>org.openhab.homematic.tracker</artifactId>
  1. Added this project to the “openhab2-addons/bundles” folder
  2. In the “openhab2-addons/bundles/pom.xml” put:
...
<module>org.openhab.homematic.tracker</module>
...
  1. In the “openhab2-addons/bom/openhab-addons/pom.xml” put:
...
  <dependency>
      <groupId>org.openhab.addons.bundles</groupId>
      <artifactId>org.openhab.homematic.tracker</artifactId>
      <version>2.5.0-SNAPSHOT</version>
  </dependency>
...
  1. In the “openhab2-addons/features/openhab-addons/src/main/feature/feature.xml” put:
...
   <feature name="openahb-homematic-tracker" description="Homematic Tracker" version="${project.version}">
        <feature>openhab-runtime-base</feature>
        <bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.homematic.tracker/${project.version}</bundle>
  </feature>

...
  1. Did the same as above for the second project “org.openhab.lamp.responder”, which has a reference to the first project service, so it also imports one class from that project.

The import resolved in the workspace , but once i try doing

mvn clean install -DskipTest -DskipChecks

in “openhab2-addons/bundles” folder, i get an error for my “org.openhab.lamp.responder” project, saying it cannot resolve the class it is importing from my “org.openhab.homematic.tracker” project.

Everything else resolves and compiles when i skip my “org.openhab.lamp.responder” in maven compilation. “org.openhab.homematic.tracker” project which exports that class compiles and in the generated jar the manifest has the export lines for the needed packages.

Any ideas, tips or suggestions? I tried looking at other bundles in the “openhab2-addons/bundles”, but could not find anything that is different from my bundles. I’m kind of running low on ideas.

Did you add a dependency to the second project’s pom to your first project?

Hi.

So i tried this before and it did not work, but because i now have changed the start of my bundles to “org.openhab.*” from whatever it was before, i thought i would try again. And this time it seems to work!

Is this somehow related, that if the bundle one wants to import is inside “openhab2-addons/bundles” folder and does not start with “org.openhab”, maven will not resolve it as an import to another bundle?

No. Maven resolves what is available in the local or defined repositories. If you add the dependency, maven will see if the artifact is available locally (on windows ~/.m2) and if that succeeds it will use that.

But: Maybe something keeps your bundle from being deployed to that repo if it‘s not in the correct namespace?

Hm, maybe. I will try to play around with this a bit more when i will have time.

Thanks.