No3x
(Christian)
October 24, 2020, 6:19pm
1
Is it possible to develop a binding without downloading the openhab-addons repository and developing as submodule by just using dependencies on openhab-core? The binding will not be published and is not intended to become part of the openhab-addons repo.
I tried the following :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>my</groupId>
<artifactId>project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>project-openhab-binding</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<ohc.version>2.5.0</ohc.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>openhab-release</id>
<name>openHAB Release Repository</name>
<url>${oh.repo.releaseBaseUrl}/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jcenter</id>
<name>JCenter Repository</name>
<url>https://jcenter.bintray.com</url>
</pluginRepository>
<pluginRepository>
<id>openhab-release</id>
<name>openHAB Release Repository</name>
<url>${oh.repo.releaseBaseUrl}/libs-release</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.compile</artifactId>
<type>pom</type>
<version>${ohc.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.openhab-core</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.runtime</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.test</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.compile-model</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
This satisfies the dependencies to compile a simple minimal binding. But to actually build a functioning jar there are more steps required. I tried to copy all maven plugin configurations from https://github.com/openhab/openhab-addons/blob/2.5.x/pom.xml but without success. The MANIFEST.MF is too empty:
Manifest-Version: 1.0
Built-By: me
Created-By: Apache Maven 3.6.3
Build-Jdk: 1.8.0_211
It should look like this:
Manifest-Version: 1.0
Bundle-Description: This project contains the official add-ons of open
HAB
Automatic-Module-Name: org.openhab.binding.ledbrightnesscalculator
Bundle-License: "Eclipse Public License 2.0";link="https://www.eclipse
.org/legal/epl-2.0/"
Bundle-SymbolicName: org.openhab.binding.ledbrightnesscalculator
Built-By: me
Bnd-LastModified: 1603563346774
Bundle-ManifestVersion: 2
Bundle-DocURL: https://github.com/openhab/infrastructure/org.openhab.a
ddons.reactor/org.openhab.addons.reactor.bundles/org.openhab.binding.
ledbrightnesscalculator
Bundle-Vendor: openHAB.org
Import-Package: org.eclipse.smarthome.core.library.types,org.eclipse.s
marthome.core.thing,org.eclipse.smarthome.core.thing.binding,org.ecli
pse.smarthome.core.types,org.slf4j;version="[1.7,2)"
Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.compo
nent)(version>=1.4.0)(!(version>=2.0.0)))",osgi.ee;filter:="(&(osgi.e
e=JavaSE)(version=1.8))"
Service-Component: OSGI-INF/org.openhab.binding.ledbrightnesscalculato
r.internal.LedBrightnessCalculatorHandlerFactory.xml
Bundle-Developers: openhab;email="info@openhab.org";name=openHAB;organ
ization=openHAB;organizationUrl="https://www.openHAB.org"
Tool: Bnd-4.3.0.201909301554
Provide-Capability: osgi.service;objectClass:List<String>="org.eclipse
.smarthome.core.thing.binding.ThingHandlerFactory";uses:="org.eclipse
.smarthome.core.thing.binding"
Bundle-Name: openHAB Add-ons :: Bundles :: LedBrightnessCalculator Bin
ding
Bundle-Version: 2.5.10.202010241815
Bundle-SCM: url="https://github.com/openhab/openhab-addons/org.openhab
.addons.reactor.bundles/org.openhab.binding.ledbrightnesscalculator",
connection="scm:git:https://github.com/openhab/openhab-addons.git/org
.openhab.addons.reactor.bundles/org.openhab.binding.ledbrightnesscalc
ulator",developer-connection="scm:git:https://github.com/openhab/open
hab-addons.git/org.openhab.addons.reactor.bundles/org.openhab.binding
.ledbrightnesscalculator",tag=HEAD
Private-Package: ESH-INF.binding,ESH-INF.i18n,ESH-INF.thing,org.openha
b.binding.ledbrightnesscalculator.internal,org.openhab.binding.ledbri
ghtnesscalculator.internal.adapter,org.openhab.binding.ledbrightnessc
alculator.internal.config,org.openhab.binding.ledbrightnesscalculator
.internal.handler
Created-By: 1.8.0_211 (Oracle Corporation)
Build-Jdk: 1.8.0_211
Did somebody tried to archive the same before me with success?
J-N-K
(Jan N. Klug)
October 24, 2020, 6:41pm
2
Your are missing the bnd-configuration,
No3x
(Christian)
October 24, 2020, 6:49pm
3
I copied the bnd stuff from the pom as well. So that my pom currently looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>my</groupId>
<artifactId>project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>project-openhab-binding</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<ohc.version>2.5.0</ohc.version>
<bnd.version>4.3.0</bnd.version>
<karaf.version>4.2.7</karaf.version>
<sat.version>0.9.0</sat.version>
<slf4j.version>1.7.21</slf4j.version>
<bnd.importpackage/>
<bnd.exportpackage/>
<bnd.includeresource>-${.}/NOTICE, -${.}/*.xsd</bnd.includeresource>
<feature.directory>src/main/feature/feature.xml</feature.directory>
<spotless.version>2.0.3</spotless.version>
<oh.repo.releaseBaseUrl>https://openhab.jfrog.io/openhab</oh.repo.releaseBaseUrl>
<oh.repo.snapshotBaseUrl>${oh.repo.releaseBaseUrl}</oh.repo.snapshotBaseUrl>
</properties>
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>openhab-release</id>
<name>openHAB Release Repository</name>
<url>${oh.repo.releaseBaseUrl}/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jcenter</id>
<name>JCenter Repository</name>
<url>https://jcenter.bintray.com</url>
</pluginRepository>
<pluginRepository>
<id>openhab-release</id>
<name>openHAB Release Repository</name>
<url>${oh.repo.releaseBaseUrl}/libs-release</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.compile</artifactId>
<type>pom</type>
<version>${ohc.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.openhab-core</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.runtime</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.test</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.compile-model</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- BEG: bnd -->
<!-- Use the bnd-maven-plugin and assemble the symbolic names -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<bnd><![CDATA[Bundle-SymbolicName: ${project.artifactId}
Automatic-Module-Name: ${def;bsn}
Import-Package: \\
io.swagger.annotations.*;resolution:=optional,\\
javax.annotation.security.*;resolution:=optional,\\
org.eclipse.jdt.annotation.*;resolution:=optional,\\
org.openhab.core.automation.annotation.*;resolution:=optional;version=!,\\
org.eclipse.smarthome.*;version=!,\\
org.openhab.*;version=!,\\
com.google.common.*;version="14.0",\\
${bnd.importpackage},\\
*
-exportcontents: \\
!*.internal.*,\\
!*.impl.*, \\
org.openhab.*, \\
${bnd.exportpackage}
-sources: false
-contract: *
-includeresource: ${bnd.includeresource}]]></bnd>
<!-- -dsannotations-options: norequirements -->
<!-- Bundle-SymbolicName: ${project.groupId}.${project.artifactId} -->
</configuration>
<executions>
<execution>
<goals>
<goal>bnd-process</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Required to make the maven-jar-plugin pick up the bnd generated manifest. Also avoid packaging empty Jars -->
<!-- Moved... -->
<!-- Setup the indexer for running and testing -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-indexer-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<localURLs>REQUIRED</localURLs>
<attach>false</attach>
</configuration>
<executions>
<execution>
<id>index</id>
<goals>
<goal>index</goal>
</goals>
<configuration>
<indexName>${project.artifactId}</indexName>
</configuration>
</execution>
<execution>
<id>test-index</id>
<goals>
<goal>index</goal>
</goals>
<configuration>
<indexName>${project.artifactId}</indexName>
<outputFile>${project.build.directory}/test-index.xml</outputFile>
<scopes>
<scope>test</scope>
</scopes>
</configuration>
</execution>
</executions>
</plugin>
<!-- Define the version of the resolver plugin we use -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-resolver-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<failOnChanges>false</failOnChanges>
<bndruns/>
</configuration>
<executions>
<execution>
<goals>
<goal>resolve</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Define the version of the export plugin we use -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-export-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<resolve>true</resolve>
<failOnChanges>true</failOnChanges>
</configuration>
<executions>
<execution>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Define the version of the testing plugin that we use -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-testing-maven-plugin</artifactId>
<version>${bnd.version}</version>
<executions>
<execution>
<goals>
<goal>testing</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Define the version of the baseline plugin we use and avoid failing when no baseline jar exists. -->
<!-- (for example before the first release) -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-baseline-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<failOnMissing>false</failOnMissing>
</configuration>
<executions>
<execution>
<goals>
<goal>baseline</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- END: bnd -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerId>eclipse</compilerId>
<compilerArgs>
<arg>-err:+nullAnnot(org.eclipse.jdt.annotation.Nullable|org.eclipse.jdt.annotation.NonNull|org.eclipse.jdt.annotation.NonNullByDefault),+inheritNullAnnot,-nullUncheckedConversion</arg>
<arg>-warn:+null,+inheritNullAnnot,+nullAnnotConflict,-nullUncheckedConversion,+nullAnnotRedundant,+nullDereference</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>ecj</artifactId>
<version>3.16.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<failOnError>!${quality.skip}</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<preparationGoals>clean install</preparationGoals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>3.0</version>
<configuration>
<basedir>${basedir}</basedir>
<header>licenses/epl-2.0/header.txt</header>
<quiet>false</quiet>
<failIfMissing>true</failIfMissing>
<strictCheck>true</strictCheck>
<aggregate>true</aggregate>
<mapping>
<xml>xml-header-style</xml>
</mapping>
<headerDefinitions>
<headerDefinition>licenses/epl-2.0/xml-header-style.xml</headerDefinition>
</headerDefinitions>
<includes>
<include>**/org/openhab/**/*.java</include>
<include>**/features/**/header.xml</include>
</includes>
<excludes>
<exclude>target/**</exclude>
<exclude>**/pom.xml</exclude>
<exclude>_*.java</exclude>
</excludes>
<useDefaultExcludes>true</useDefaultExcludes>
<properties>
<year>2020</year>
</properties>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openhab.tools.sat</groupId>
<artifactId>sat-plugin</artifactId>
<version>${sat.version}</version>
<configuration>
<checkstyleProperties>${basedirRoot}/tools/static-code-analysis/checkstyle/ruleset.properties</checkstyleProperties>
<checkstyleFilter>${basedirRoot}/tools/static-code-analysis/checkstyle/suppressions.xml</checkstyleFilter>
</configuration>
<executions>
<execution>
<id>sat-all</id>
<goals>
<goal>checkstyle</goal>
<goal>pmd</goal>
<goal>spotbugs</goal>
<goal>report</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless.version}</version>
<configuration>
<java>
<eclipse>
<file>openhab_codestyle.xml</file>
<version>4.13.0</version>
</eclipse>
<removeUnusedImports/>
<importOrder>
<file>openhab.importorder</file>
</importOrder>
<endWithNewline/>
</java>
<formats>
<format>
<!-- *.xml -->
<includes>
<include>src/**/*.xml</include>
</includes>
<excludes>
<exclude>**/pom.xml</exclude>
<exclude>**/feature.xml</exclude>
<exclude>src/main/history/**/*.xml</exclude>
<exclude>src/main/resources/header.xml</exclude>
<exclude>src/main/resources/footer.xml</exclude>
<exclude>src/main/resources/input/rss*.xml</exclude>
<exclude>src/test/resources/**/*.xml</exclude>
</excludes>
<eclipseWtp>
<type>XML</type>
<files>
<file>openhab_wst_xml_files.prefs</file>
</files>
<version>4.13.0</version>
</eclipseWtp>
<trimTrailingWhitespace/>
<endWithNewline/>
</format>
<format>
<!-- feature.xml -->
<includes>
<include>**/src/main/feature/feature.xml</include>
</includes>
<eclipseWtp>
<type>XML</type>
<files>
<file>openhab_wst_feature_file.prefs</file>
</files>
<version>4.13.0</version>
</eclipseWtp>
<trimTrailingWhitespace/>
<endWithNewline/>
</format>
<format>
<!-- pom.xml -->
<includes>
<include>pom.xml</include>
</includes>
<eclipseWtp>
<type>XML</type>
<files>
<file>openhab_wst_pom_file.prefs</file>
</files>
<version>4.13.0</version>
</eclipseWtp>
<trimTrailingWhitespace/>
<endWithNewline/>
</format>
</formats>
</configuration>
<dependencies>
<dependency>
<groupId>org.openhab.tools</groupId>
<artifactId>openhab-codestyle</artifactId>
<version>0.10.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>codestyle_check</id>
<goals>
<goal>check</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.8.0-40,1.9),[9.0,12.0)</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.openhab.tools.sat</groupId>
<artifactId>sat-extension</artifactId>
<version>${sat.version}</version>
</extension>
</extensions>
</build>
<profiles>
<profile>
<id>skip-check</id>
<activation>
<property>
<name>skipChecks</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.openhab.tools.sat</groupId>
<artifactId>sat-plugin</artifactId>
<version>${sat.version}</version>
<executions>
<execution>
<id>sat-all</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>check-bundles</id>
<activation>
<file>
<exists>src</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.openhab.tools.sat</groupId>
<artifactId>sat-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>add-libraries-cli</id>
<activation>
<property>
<name>!m2e.version</name>
</property>
<file>
<exists>lib/</exists>
</file>
</activation>
<properties>
<bnd.includeresource>-${.}/../../NOTICE, -${.}/../../*.xsd, ${.}/../../lib/;filter:=*.jar;lib:=true</bnd.includeresource>
<feature.directory>../../src/main/feature/feature.xml</feature.directory>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.addjars-maven-plugin</groupId>
<artifactId>addjars-maven-plugin</artifactId>
<version>1.0.5</version>
<executions>
<execution>
<goals>
<goal>add-jars</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${project.basedir}/lib</directory>
<includes>
<include>**/*.jar</include>
</includes>
<scope>provided</scope>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>add-libraries-eclipse</id>
<activation>
<property>
<name>m2e.version</name>
</property>
<file>
<exists>lib/</exists>
</file>
</activation>
<properties>
<bnd.includeresource>-${.}/NOTICE, -${.}/*.xsd, ${.}/lib/;filter:=*.jar;lib:=true</bnd.includeresource>
</properties>
</profile>
<profile>
<id>with-bnd-resolver-resolve</id>
<activation>
<property>
<name>withResolver</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-resolver-maven-plugin</artifactId>
<version>${bnd.version}</version>
<executions>
<execution>
<goals>
<goal>resolve</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
</project>
I guess the bnd stuff (Import-Package:
) is not correct. But it should output a better MANIFEST anyway (I guess). I don’t know much about the bnd part. Probably that’s part of my issue.
Additional Information:
My code lives in org.openhab.binding.ledbrightnesscalculator.internal
No3x
(Christian)
October 24, 2020, 10:48pm
4
Added the following configuration (in particular maven-jar-plugin):
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
<skipIfEmpty>true</skipIfEmpty>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf.version}</version>
<extensions>true</extensions>
<configuration>
<startLevel>80</startLevel>
<aggregateFeatures>true</aggregateFeatures>
<checkDependencyChange>true</checkDependencyChange>
<failOnDependencyChange>false</failOnDependencyChange>
<logDependencyChanges>true</logDependencyChanges>
<overwriteChangedDependencies>true</overwriteChangedDependencies>
</configuration>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>features-generate-descriptor</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<inputFile>${feature.directory}</inputFile>
</configuration>
</execution>
<execution>
<id>karaf-feature-verification</id>
<goals>
<goal>verify</goal>
</goals>
<phase>verify</phase>
<configuration>
<descriptors combine.children="append">
<!-- Apache Karaf -->
<descriptor>mvn:org.apache.karaf.features/framework/${karaf.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features</descriptor>
<!-- Current feature under verification -->
<descriptor>file:${project.build.directory}/feature/feature.xml</descriptor>
</descriptors>
<distribution>org.apache.karaf.features:framework</distribution>
<javase>1.8</javase>
<framework>
<feature>framework</feature>
</framework>
<features>
<feature>openhab-*</feature>
</features>
<verifyTransitive>false</verifyTransitive>
<ignoreMissingConditions>true</ignoreMissingConditions>
<fail>first</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
So that the complete pom is:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>my</groupId>
<artifactId>project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>project-openhab-binding</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<ohc.version>2.5.0</ohc.version>
<bnd.version>4.3.0</bnd.version>
<karaf.version>4.2.7</karaf.version>
<sat.version>0.9.0</sat.version>
<slf4j.version>1.7.21</slf4j.version>
<bnd.importpackage/>
<bnd.exportpackage/>
<bnd.includeresource>-${.}/NOTICE, -${.}/*.xsd</bnd.includeresource>
<feature.directory>src/main/feature/feature.xml</feature.directory>
<spotless.version>2.0.3</spotless.version>
<oh.repo.releaseBaseUrl>https://openhab.jfrog.io/openhab</oh.repo.releaseBaseUrl>
<oh.repo.snapshotBaseUrl>${oh.repo.releaseBaseUrl}</oh.repo.snapshotBaseUrl>
</properties>
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>openhab-release</id>
<name>openHAB Release Repository</name>
<url>${oh.repo.releaseBaseUrl}/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jcenter</id>
<name>JCenter Repository</name>
<url>https://jcenter.bintray.com</url>
</pluginRepository>
<pluginRepository>
<id>openhab-release</id>
<name>openHAB Release Repository</name>
<url>${oh.repo.releaseBaseUrl}/libs-release</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.compile</artifactId>
<type>pom</type>
<version>${ohc.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.openhab-core</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.runtime</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.test</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.compile-model</artifactId>
<version>${ohc.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
<skipIfEmpty>true</skipIfEmpty>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf.version}</version>
<extensions>true</extensions>
<configuration>
<startLevel>80</startLevel>
<aggregateFeatures>true</aggregateFeatures>
<checkDependencyChange>true</checkDependencyChange>
<failOnDependencyChange>false</failOnDependencyChange>
<logDependencyChanges>true</logDependencyChanges>
<overwriteChangedDependencies>true</overwriteChangedDependencies>
</configuration>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>features-generate-descriptor</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<inputFile>${feature.directory}</inputFile>
</configuration>
</execution>
<execution>
<id>karaf-feature-verification</id>
<goals>
<goal>verify</goal>
</goals>
<phase>verify</phase>
<configuration>
<descriptors combine.children="append">
<!-- Apache Karaf -->
<descriptor>mvn:org.apache.karaf.features/framework/${karaf.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features</descriptor>
<!-- Current feature under verification -->
<descriptor>file:${project.build.directory}/feature/feature.xml</descriptor>
</descriptors>
<distribution>org.apache.karaf.features:framework</distribution>
<javase>1.8</javase>
<framework>
<feature>framework</feature>
</framework>
<features>
<feature>openhab-*</feature>
</features>
<verifyTransitive>false</verifyTransitive>
<ignoreMissingConditions>true</ignoreMissingConditions>
<fail>first</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- BEG: bnd -->
<!-- Use the bnd-maven-plugin and assemble the symbolic names -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<bnd><![CDATA[Bundle-SymbolicName: ${project.artifactId}
Automatic-Module-Name: ${def;bsn}
Import-Package: \\
io.swagger.annotations.*;resolution:=optional,\\
javax.annotation.security.*;resolution:=optional,\\
org.eclipse.jdt.annotation.*;resolution:=optional,\\
org.openhab.core.automation.annotation.*;resolution:=optional;version=!,\\
org.eclipse.smarthome.*;version=!,\\
org.openhab.*;version=!,\\
com.google.common.*;version="14.0",\\
${bnd.importpackage},\\
*
-exportcontents: \\
!*.internal.*,\\
!*.impl.*, \\
org.openhab.*, \\
${bnd.exportpackage}
-sources: false
-contract: *
-includeresource: ${bnd.includeresource}]]></bnd>
<!-- -dsannotations-options: norequirements -->
<!-- Bundle-SymbolicName: ${project.groupId}.${project.artifactId} -->
</configuration>
<executions>
<execution>
<goals>
<goal>bnd-process</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Required to make the maven-jar-plugin pick up the bnd generated manifest. Also avoid packaging empty Jars -->
<!-- Moved... -->
<!-- Setup the indexer for running and testing -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-indexer-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<localURLs>REQUIRED</localURLs>
<attach>false</attach>
</configuration>
<executions>
<execution>
<id>index</id>
<goals>
<goal>index</goal>
</goals>
<configuration>
<indexName>${project.artifactId}</indexName>
</configuration>
</execution>
<execution>
<id>test-index</id>
<goals>
<goal>index</goal>
</goals>
<configuration>
<indexName>${project.artifactId}</indexName>
<outputFile>${project.build.directory}/test-index.xml</outputFile>
<scopes>
<scope>test</scope>
</scopes>
</configuration>
</execution>
</executions>
</plugin>
<!-- Define the version of the resolver plugin we use -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-resolver-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<failOnChanges>false</failOnChanges>
<bndruns/>
</configuration>
<executions>
<execution>
<goals>
<goal>resolve</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Define the version of the export plugin we use -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-export-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<resolve>true</resolve>
<failOnChanges>true</failOnChanges>
</configuration>
<executions>
<execution>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Define the version of the testing plugin that we use -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-testing-maven-plugin</artifactId>
<version>${bnd.version}</version>
<executions>
<execution>
<goals>
<goal>testing</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Define the version of the baseline plugin we use and avoid failing when no baseline jar exists. -->
<!-- (for example before the first release) -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-baseline-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<failOnMissing>false</failOnMissing>
</configuration>
<executions>
<execution>
<goals>
<goal>baseline</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- END: bnd -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerId>eclipse</compilerId>
<compilerArgs>
<arg>-err:+nullAnnot(org.eclipse.jdt.annotation.Nullable|org.eclipse.jdt.annotation.NonNull|org.eclipse.jdt.annotation.NonNullByDefault),+inheritNullAnnot,-nullUncheckedConversion</arg>
<arg>-warn:+null,+inheritNullAnnot,+nullAnnotConflict,-nullUncheckedConversion,+nullAnnotRedundant,+nullDereference</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>ecj</artifactId>
<version>3.16.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<failOnError>!${quality.skip}</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<preparationGoals>clean install</preparationGoals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>3.0</version>
<configuration>
<basedir>${basedir}</basedir>
<header>licenses/epl-2.0/header.txt</header>
<quiet>false</quiet>
<failIfMissing>true</failIfMissing>
<strictCheck>true</strictCheck>
<aggregate>true</aggregate>
<mapping>
<xml>xml-header-style</xml>
</mapping>
<headerDefinitions>
<headerDefinition>licenses/epl-2.0/xml-header-style.xml</headerDefinition>
</headerDefinitions>
<includes>
<include>**/org/openhab/**/*.java</include>
<include>**/features/**/header.xml</include>
</includes>
<excludes>
<exclude>target/**</exclude>
<exclude>**/pom.xml</exclude>
<exclude>_*.java</exclude>
</excludes>
<useDefaultExcludes>true</useDefaultExcludes>
<properties>
<year>2020</year>
</properties>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openhab.tools.sat</groupId>
<artifactId>sat-plugin</artifactId>
<version>${sat.version}</version>
<configuration>
<checkstyleProperties>${basedirRoot}/tools/static-code-analysis/checkstyle/ruleset.properties</checkstyleProperties>
<checkstyleFilter>${basedirRoot}/tools/static-code-analysis/checkstyle/suppressions.xml</checkstyleFilter>
</configuration>
<executions>
<execution>
<id>sat-all</id>
<goals>
<goal>checkstyle</goal>
<goal>pmd</goal>
<goal>spotbugs</goal>
<goal>report</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless.version}</version>
<configuration>
<java>
<eclipse>
<file>openhab_codestyle.xml</file>
<version>4.13.0</version>
</eclipse>
<removeUnusedImports/>
<importOrder>
<file>openhab.importorder</file>
</importOrder>
<endWithNewline/>
</java>
<formats>
<format>
<!-- *.xml -->
<includes>
<include>src/**/*.xml</include>
</includes>
<excludes>
<exclude>**/pom.xml</exclude>
<exclude>**/feature.xml</exclude>
<exclude>src/main/history/**/*.xml</exclude>
<exclude>src/main/resources/header.xml</exclude>
<exclude>src/main/resources/footer.xml</exclude>
<exclude>src/main/resources/input/rss*.xml</exclude>
<exclude>src/test/resources/**/*.xml</exclude>
</excludes>
<eclipseWtp>
<type>XML</type>
<files>
<file>openhab_wst_xml_files.prefs</file>
</files>
<version>4.13.0</version>
</eclipseWtp>
<trimTrailingWhitespace/>
<endWithNewline/>
</format>
<format>
<!-- feature.xml -->
<includes>
<include>**/src/main/feature/feature.xml</include>
</includes>
<eclipseWtp>
<type>XML</type>
<files>
<file>openhab_wst_feature_file.prefs</file>
</files>
<version>4.13.0</version>
</eclipseWtp>
<trimTrailingWhitespace/>
<endWithNewline/>
</format>
<format>
<!-- pom.xml -->
<includes>
<include>pom.xml</include>
</includes>
<eclipseWtp>
<type>XML</type>
<files>
<file>openhab_wst_pom_file.prefs</file>
</files>
<version>4.13.0</version>
</eclipseWtp>
<trimTrailingWhitespace/>
<endWithNewline/>
</format>
</formats>
</configuration>
<dependencies>
<dependency>
<groupId>org.openhab.tools</groupId>
<artifactId>openhab-codestyle</artifactId>
<version>0.10.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>codestyle_check</id>
<goals>
<goal>check</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.8.0-40,1.9),[9.0,12.0)</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.openhab.tools.sat</groupId>
<artifactId>sat-extension</artifactId>
<version>${sat.version}</version>
</extension>
</extensions>
</build>
<profiles>
<profile>
<id>skip-check</id>
<activation>
<property>
<name>skipChecks</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.openhab.tools.sat</groupId>
<artifactId>sat-plugin</artifactId>
<version>${sat.version}</version>
<executions>
<execution>
<id>sat-all</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>check-bundles</id>
<activation>
<file>
<exists>src</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.openhab.tools.sat</groupId>
<artifactId>sat-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>add-libraries-cli</id>
<activation>
<property>
<name>!m2e.version</name>
</property>
<file>
<exists>lib/</exists>
</file>
</activation>
<properties>
<bnd.includeresource>-${.}/../../NOTICE, -${.}/../../*.xsd, ${.}/../../lib/;filter:=*.jar;lib:=true</bnd.includeresource>
<feature.directory>../../src/main/feature/feature.xml</feature.directory>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.addjars-maven-plugin</groupId>
<artifactId>addjars-maven-plugin</artifactId>
<version>1.0.5</version>
<executions>
<execution>
<goals>
<goal>add-jars</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${project.basedir}/lib</directory>
<includes>
<include>**/*.jar</include>
</includes>
<scope>provided</scope>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>add-libraries-eclipse</id>
<activation>
<property>
<name>m2e.version</name>
</property>
<file>
<exists>lib/</exists>
</file>
</activation>
<properties>
<bnd.includeresource>-${.}/NOTICE, -${.}/*.xsd, ${.}/lib/;filter:=*.jar;lib:=true</bnd.includeresource>
</properties>
</profile>
<profile>
<id>with-bnd-resolver-resolve</id>
<activation>
<property>
<name>withResolver</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-resolver-maven-plugin</artifactId>
<version>${bnd.version}</version>
<executions>
<execution>
<goals>
<goal>resolve</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
</project>
It works. Probably not all functionality works because this is kind of hacked but for my basic binding it is sufficient to build a jar, that is functional (putting it into addons dir works, thing is there, can link items to a channel).