Developping on openhab-core with VS Code

With reference to Starting demo app takes ages (10-12min on every "Run OSGi" startup) - #26 by kgoderis and https://www.openhab.org/docs/developer/ide/vscode.html I was wondering what is the correct approach to development on openhab-core

My intent was to just add the code to openhab-core, then compile openhab-distro, deploy that and remotely debug against that instance.

I have the case that I want to contribute a pure java serial transport bundle as replacement for the RXTX one and the regular javacomm bundle because as it stands RXTX does not provide binaries for Apple’s ARM64 platform.

I have added

	<feature name="openhab.tp-serial-purejavacomm" version="${project.version}">
		<capability>openhab.tp;feature=serial;impl=purejavacomm</capability>
		<bundle>mvn:org.opensmarthouse/purejavacomm/1.0.5</bundle>
	</feature>

to /openhab-core/features/karaf/openhab-tp/src/main/feature/feature.xml and developed the bundle, after every compilation ends with

[**ERROR**] Failed to execute goal org.apache.karaf.tooling:karaf-maven-plugin:4.4.3:verify **(karaf-feature-verification)** on project org.openhab.core.features.karaf.openhab-tp: **Feature resolution failed for [openhab.tp-serial-purejavacomm/4.0.0.SNAPSHOT]**

[**ERROR**] **Message: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=openhab.tp-serial-purejavacomm; type=karaf.feature; version=4.0.0.SNAPSHOT; filter:="(&(osgi.identity=openhab.tp-serial-purejavacomm)(type=karaf.feature)(version>=4.0.0.SNAPSHOT))" [caused by: Unable to resolve openhab.tp-serial-purejavacomm/4.0.0.SNAPSHOT: missing requirement [openhab.tp-serial-purejavacomm/4.0.0.SNAPSHOT] osgi.identity; osgi.identity=purejavacomm; type=osgi.bundle; version="[1.0.5,1.0.5]"; resolution:=mandatory [caused by: Unable to resolve purejavacomm/1.0.5: missing requirement [purejavacomm/1.0.5] osgi.wiring.package; filter:="(&(osgi.wiring.package=com.sun.jna)(version>=5.6.0)(!(version>=6.0.0)))"]]**

[**ERROR**] **Repositories: {**

[**ERROR**] **file:/Users/kgoderis/Development/openhab/git/openhab-core/features/karaf/openhab-tp/target/feature/feature.xml**

[**ERROR**] **mvn:org.apache.karaf.features/framework/4.4.3/xml/features**

[**ERROR**] **mvn:org.apache.karaf.features/standard/4.4.3/xml/features**

[**ERROR**] **mvn:org.ops4j.pax.web/pax-web-features/8.0.15/xml/features**

[**ERROR**] **}**

[**ERROR**] **Resources: {**

[**ERROR**] **mvn:org.apache.felix/org.apache.felix.cm.json/1.0.6**

[**ERROR**] **mvn:org.apache.felix/org.apache.felix.configadmin.plugin.interpolation/1.2.6**

[**ERROR**] **mvn:org.apache.felix/org.apache.felix.configadmin/1.9.26**

[**ERROR**] **mvn:org.apache.felix/org.apache.felix.configurator/1.0.16**

[**ERROR**] **mvn:org.apache.felix/org.apache.felix.converter/1.0.14**

[**ERROR**] **mvn:org.apache.felix/org.apache.felix.coordinator/1.0.2**

[**ERROR**] **mvn:org.apache.felix/org.apache.felix.fileinstall/3.7.4**

[**ERROR**] **mvn:org.apache.karaf.config/org.apache.karaf.config.core/4.4.3**

[**ERROR**] **mvn:org.apache.karaf.features/org.apache.karaf.features.core/4.4.3**

[**ERROR**] **mvn:org.apache.karaf.features/org.apache.karaf.features.extension/4.4.3**

[**ERROR**] **mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxb-api-2.2/2.9.0**

[**ERROR**] **mvn:org.apache.sling/org.apache.sling.commons.johnzon/1.2.14**

[**ERROR**] **mvn:org.fusesource.jansi/jansi/2.4.0**

[**ERROR**] **mvn:org.opensmarthouse/purejavacomm/1.0.5**

[**ERROR**] **mvn:org.ops4j.pax.logging/pax-logging-api/2.2.0**

[**ERROR**] **mvn:org.ops4j.pax.logging/pax-logging-log4j2/2.2.0**

[**ERROR**] **mvn:org.ops4j.pax.url/pax-url-aether/2.6.12**

[**ERROR**] **mvn:org.osgi/org.osgi.util.function/1.2.0**

[**ERROR**] **mvn:org.osgi/org.osgi.util.promise/1.2.0**

[**ERROR**] **}**

[**ERROR**] -> **[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/MojoExecutionException

[**ERROR**]

[**ERROR**] After correcting the problems, you can resume the build with the command

[**ERROR**] **mvn <args> -rf :org.openhab.core.features.karaf.openhab-tp**

The bundle itself compiles fine, and resolves the dependency which is nicely downloaded in ~/.m2

I have also added to features/karaf/openhab-core/src/main/feature/feature.xml the following snippet :

	<feature name="openhab-core-io-transport-serial-purejavacomm" version="${project.version}">
		<feature>openhab-core-base</feature>

		<requirement>openhab.tp;filter:="(&amp;(feature=serial)(impl=purejavacomm))"</requirement>
		<feature dependency="true">openhab.tp-serial-purejavacomm</feature>

		<bundle>mvn:org.openhab.core.bundles/org.openhab.core.io.transport.serial/${project.version}</bundle>
		<bundle>mvn:org.openhab.core.bundles/org.openhab.core.io.transport.serial.purejavacomm/${project.version}</bundle>
	</feature>

What am I missing here?

The requirement and capability elements in feature files are not resolved automatically so it is “art for an art”.

Error message you see would be probably the same with command line call to mvn, cause you miss JNA dependency.
Have a look here: connectorio-addons/feature.xml at 76a2541dcb5c5d2f618aec921526f9e7ce981593 · ConnectorIO/connectorio-addons · GitHub

If JNA on openHAB side is updated then you just need to point specific openhab.tp- feature.

Thanks, btw, it is your original contribution that I try to leverage and bring to the distribution. I was looking at your repo to understand what I was missing to get it properly built

No problem, luckily purejavacomm is pretty close to old rxtx api so it was easy to integrate. With regard to distro there is serial.rfc2217 bundle which as far I remember is bound to rxtx.

One thing - maybe it would be good idea to use conditional features depending on operating system and its architecture?

Thanks, works like a charm now

However, I could not find any decent doc on how to do al feature.xml’s.

Apache Karaf docs might be a help: Provisioning. It does have a paragraph about requirements, but not on conditions. I have to verify that.
Anyway, let me know which part of above docs is incomplete. I can work on improving it.

Cheers,
Łukasz