Build error on clean git source of openhab-addons v3.4.2

I’m having problems with building clean 3.4.2 addons. What I did:

  1. clone the source from github
  2. checkout 3.4.2 tag (detached head state)
  3. create branch 3.4.2
  4. run mvn clean install
  5. boom - error with formatting (I can fix it with mvn spotless:apply)
    The error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.140 s
[INFO] Finished at: 2023-04-08T11:41:27+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:2.0.3:check (codestyle_check) on project org.openhab.addons.reactor: The following files had format violations:
[ERROR]     pom.xml
[ERROR]         @@ -1,4 +1,6 @@
[ERROR]         -<?xml·version="1.0"·encoding="UTF-8"·standalone="no"?><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·https://maven.apache.org/xsd/maven-4.0.0.xsd">
[ERROR]         +<?xml·version="1.0"·encoding="UTF-8"·standalone="no"?>
[ERROR]         +<project·xmlns="http://maven.apache.org/POM/4.0.0"·xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
[ERROR]         +··xsi:schemaLocation="http://maven.apache.org/POM/4.0.0·https://maven.apache.org/xsd/maven-4.0.0.xsd">
[ERROR]          ··<modelVersion>4.0.0</modelVersion>
[ERROR]          
[ERROR]          ··<parent>
[ERROR] Run 'mvn spotless:apply' to fix these violations.
[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

My setup:

$ cat /etc/fedora-release 
Fedora release 36 (Thirty Six)
fedora:/home/przemo/software/openhab-addons
$ mvn -v
Apache Maven 3.8.4 (Red Hat 3.8.4-3)
Maven home: /usr/share/maven
Java version: 17.0.6, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-17-openjdk-17.0.6.0.10-1.fc36.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.2.8-100.fc36.x86_64", arch: "amd64", family: "unix"
fedora:/home/przemo/software/openhab-addons
$ java -version
openjdk version "17.0.6" 2023-01-17
OpenJDK Runtime Environment (Red_Hat-17.0.6.0.10-1.fc36) (build 17.0.6+10)
OpenJDK 64-Bit Server VM (Red_Hat-17.0.6.0.10-1.fc36) (build 17.0.6+10, mixed mode, sharing)

I use vim + syntastic for development, but that shouldn’t make any difference.
Is that normal? My goal is here. but in order to make any mods I need to be able to compile the “vanilla” version first. :grinning:

openHAB 3…x.x needs Java 11, not Java 17

1 Like

Thanks! I’ll change the version and re-test.

For release builds (and only for those should the 3.4.x branches be used) spotless checks are disabled, therefore this is not noticed. If you really need to build this branch you can add -Dspotless.check.skip=true to your command line (or apply spotless).

That aside: I would strongly recommend using a branch of main for development, otherwise it can’t be merged.

1 Like

I think that the correct version of java was used anyway as per pom.xml - I had both 11 and 17 installed. I wanted to do the changes on 3.4.2 to make sure they work, but obviously I’ll be migrating them to the main branch before making a PR.