How to build kar files for marketplace that is compatible with milestone and SNAPSHOT builds

I’ve started to deploy the Sony Binding via the community marketplace. To avoid the need to manually install features, I’ve decided to provide a kar file with all necessary feature dependencies. The build process for this kar file is as follows:

  • Use recent 3.2.0-SNAPSHOT addons codebase
  • Define feature.xml with all dependencies
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.sony-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
	<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>

	<feature name="openhab-binding-sony" description="Sony Binding" version="${project.version}">
		<feature>openhab-runtime-base</feature>
		<feature>openhab-transport-upnp</feature>
		<bundle dependency="true">mvn:org.openhab.addons.bundles/org.openhab.transform.map/${project.version}</bundle>
		<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.sony/${project.version}</bundle>
	</feature>
</features>
  • Build kar file from my fork with mvn clean install -pl :org.openhab.binding.sony karaf:kar

The generated kar file can be installed from the community marketplace from a recent 3.2.0-SNAPSHOT runtime environment (build #2549) without any issues. However, when I try to install the same kar file using the 3.2.0.M3 runtime environment, the following error is thrown:

java.lang.RuntimeException: Error resolving artifact org.openhab.core.features.karaf:org.openhab.core.features.karaf.openhab-core:xml:features:3.2.0-SNAPSHOT: [Could not find artifact org.openhab.core.features.karaf:org.openhab.core.features.karaf.openhab-core:xml:features:3.2.0-SNAPSHOT] : mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/3.2.0-SNAPSHOT/xml/features

My guess is that this is caused by the definition of the repository in the feature.xml file where ohc.version=3.2.0-SNAPSHOT. I’ve tried to set the variable `ohc.version=3.2.0.M3’ in the maven command, but this fails as this repository is not found. Also omitting the repository results in a build failure.

So my (slightly more general) question is: Is there any possibility to build a kar file that is compatible with multiple OH runtime versions (e.g. milestones and SNAPSHOT builds). If yes, how could that be achieved (by a proper feature.xml or other options)?

2 Likes

Hi Andreas,

I am using a modified POM to build *.kar files for add-ons. Here are my changes:

Adding the above changes builds *.kar files automatically for all bundles when running the mvn clean install -T 1C command.

Do you like to try it? Feedback is welcome. If it is working for you we can push it to our repository.

Best,
Christoph

1 Like

Hi Christoph,

Thanks for this apparently helpful link. I’m going to try it and will provide feedback shortly.

Andreas

I’m happy to confirm that the kar file produced by your modified POM now works under a 3.2.0-SNAPSHOT and a 3.2.0.M3 runtime versions without issues. Some observations/notes:

  • I had to delete the repository element in the feature.xml (which I assume was the source of the issue)
  • The produced kar file has a smaller file size than the jar file (why?)

Thanks again for your quick response and the provided solution.

I cannot tell you why it is small. Maybe you want to extract both archives and compare their contents. This way we might get an idea of what is in there ant if it is correct to be there or what is missing.

do you have the non-error binding kar available for download?

See the download link in this marketplace topic Sony Binding - Add-on Marketplace / Bundles - openHAB Community

Note that some users are reporting issues with the installation of this kar which I’m currently investigating. So it might be that the kar file, which I’ve created on the basis of Christoph’s pom file, might be errorneous.

1 Like

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