Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OH3: Maven build failing (bad format violations in a POM) #8712

Closed
lolodomo opened this issue Oct 10, 2020 · 35 comments
Closed

OH3: Maven build failing (bad format violations in a POM) #8712

lolodomo opened this issue Oct 10, 2020 · 35 comments

Comments

@lolodomo
Copy link
Contributor

lolodomo commented Oct 10, 2020

Even using -DskipChecks does not help avoiding this blocking step.

Is there a way to disable this check ?

[INFO] --- spotless-maven-plugin:2.0.3:check (codestyle_check) @ org.openhab.addons.reactor.bundles ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] openHAB Add-ons .................................... SUCCESS [03:12 min]
[INFO] openHAB Add-ons :: BOM ............................. SUCCESS [  0.062 s]
[INFO] openHAB Add-ons :: BOM :: Runtime Index ............ SUCCESS [03:07 min]
[INFO] openHAB Add-ons :: BOM :: Test Index ............... SUCCESS [ 22.930 s]
[INFO] openHAB Add-ons :: BOM :: openHAB Core Index ....... SUCCESS [01:54 min]
[INFO] openHAB Add-ons :: Bundles ......................... FAILURE [ 37.950 s]
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10:23 min
[INFO] Finished at: 2020-10-10T13:21:45+02:00
[INFO] Final Memory: 135M/512M
[INFO] ------------------------------------------------------------------------
[INFO] Static code analysis summary report is available in:
[INFO] file:/D:/dev/openhab2/git/openhab-addons/target/summary_report.html
[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:2.0.3:check (codestyle_check) on project org.openhab.addons.reactor.bundles: The following files had format violations:
[ERROR]     pom.xml
[ERROR]         @@ -1,554 +1,554 @@
[ERROR]         -<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r\n
[ERROR]         -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r\n
[ERROR]         -  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r\n
[ERROR]         -\r\n
[ERROR]         -  <modelVersion>4.0.0</modelVersion>\r\n
[ERROR]         -\r\n
[ERROR]         -  <parent>\r\n
[ERROR]         -    <groupId>org.openhab.addons</groupId>\r\n
[ERROR]         -    <artifactId>org.openhab.addons.reactor</artifactId>\r\n
[ERROR]         -    <version>3.0.0-SNAPSHOT</version>\r\n
[ERROR]         -  </parent>\r\n
[ERROR]         -\r\n
[ERROR]         -  <groupId>org.openhab.addons.bundles</groupId>\r\n
[ERROR]         -  <artifactId>org.openhab.addons.reactor.bundles</artifactId>\r\n
[ERROR]         -  <packaging>pom</packaging>\r\n
[ERROR]         -\r\n
[ERROR]         -  <name>openHAB Add-ons :: Bundles</name>\r\n
[ERROR]         -\r\n
[ERROR]         -  <modules>\r\n
[ERROR]         -    <!-- io -->\r\n
[ERROR]         -    <module>org.openhab.io.homekit</module>\r\n
[ERROR]         -    <module>org.openhab.io.hueemulation</module>\r\n
[ERROR]         -    <module>org.openhab.io.imperihome</module>\r\n
[ERROR]         -    <module>org.openhab.io.neeo</module>\r\n
[ERROR]         -    <module>org.openhab.io.openhabcloud</module>\r\n
[ERROR]         -    <module>org.openhab.io.transport.modbus</module>\r\n
[ERROR]         -    <!-- transformations -->\r\n
[ERROR]         -    <module>org.openhab.transform.bin2json</module>\r\n
[ERROR]         -    <module>org.openhab.transform.exec</module>\r\n
[ERROR]         -    <module>org.openhab.transform.javascript</module>\r\n
[ERROR]         -    <module>org.openhab.transform.jinja</module>\r\n
[ERROR]         -    <module>org.openhab.transform.jsonpath</module>\r\n
[ERROR]         -    <module>org.openhab.transform.map</module>\r\n
[ERROR]         -    <module>org.openhab.transform.regex</module>\r\n
[ERROR]         -    <module>org.openhab.transform.scale</module>\r\n
[ERROR]         -    <module>org.openhab.transform.xpath</module>\r\n
[ERROR]         -    <module>org.openhab.transform.xslt</module>\r\n
[ERROR]         -    <!-- bindings -->\r\n
[ERROR]         -    <module>org.openhab.binding.adorne</module>\r\n
[ERROR]         -    <module>org.openhab.binding.airquality</module>\r\n
[ERROR]         -    <module>org.openhab.binding.airvisualnode</module>\r\n
[ERROR]         -    <module>org.openhab.binding.alarmdecoder</module>\r\n
[ERROR]         -    <module>org.openhab.binding.allplay</module>\r\n
[ERROR]         -    <module>org.openhab.binding.amazondashbutton</module>\r\n
[ERROR]         -    <module>org.openhab.binding.amazonechocontrol</module>\r\n
[ERROR]         -    <module>org.openhab.binding.ambientweather</module>\r\n
[ERROR]         -    <module>org.openhab.binding.astro</module>\r\n
[ERROR]         -    <module>org.openhab.binding.atlona</module>\r\n
[ERROR]     ... (1060 more lines that didn't fit)
[ERROR] Run 'mvn spotless:apply' to fix these violations.
```
@lolodomo lolodomo added the bug An unexpected problem or unintended behavior of an add-on label Oct 10, 2020
@lolodomo
Copy link
Contributor Author

lolodomo commented Oct 10, 2020

I even don't find this project org.openhab.addons.reactor.bundles in the repo.

And the Static code analysis summary report contains no additional information.

Just to mention this is maven run just after cloning the git repo and after installing a new JDK 11.

$ git branch
* main

$ git status
On branch main
Your branch is up-to-date with 'origin/main'.
nothing to commit, working tree clean

$ java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)

$ mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06+02:00)
Maven home: C:\Program Files\apache-maven-3.5.0
Java version: 11.0.8, vendor: AdoptOpenJDK
Java home: C:\Program Files\AdoptOpenJDK\jdk-11.0.8.10-hotspot
Default locale: fr_FR, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

@lolodomo lolodomo changed the title OH3: build failing (bad format violations in a POM) OH3: Maven build failing (bad format violations in a POM) Oct 10, 2020
@J-N-K
Copy link
Member

J-N-K commented Oct 10, 2020

I run into that problem sometimes, too. I guess it‘s something with the git line-ending setting.

You can use -D“spotless.check.skip“=true to skip the check.

@lolodomo
Copy link
Contributor Author

I got the same error when running mvn clean install -D“spotless.check.skip“=true

@lolodomo
Copy link
Contributor Author

lolodomo commented Oct 10, 2020

Check bypassed if I use the following command: mvn clean install -Dspotless.check.skip=true without the ""

This is probably something to add in the documentation in addtion to -DskipChecks and -DskipTests.

@lolodomo
Copy link
Contributor Author

I am on Windows. You say if could be git line-ending setting. Could it be a wrong line encoding of this POM file ?

@J-N-K
Copy link
Member

J-N-K commented Oct 10, 2020

My feeling is that it‘s more a spotless bug (could be it doesn‘t detect the correct line-ending).

@J-N-K
Copy link
Member

J-N-K commented Oct 10, 2020

Very interestingnit works for you without the "". It‘s not working for me without. Are you using cmd („Eingabeaufforderung“ in german, not sure how it is labelled in other languages) or Powershell?

@lolodomo
Copy link
Contributor Author

lolodomo commented Oct 10, 2020

It was run from a Git Bash window.

@lolodomo
Copy link
Contributor Author

lolodomo commented Oct 10, 2020

With spotless checking disabled, the build succeeded.

@lolodomo
Copy link
Contributor Author

lolodomo commented Oct 10, 2020

It takes 1h14'. I have the feeling it takes largely more time than before (OH2) (twice the time ?).
Here are the bindings that took more than 30s to build:

[INFO] openHAB Add-ons :: Bundles :: Adorne Binding ....... SUCCESS [ 45.838 s]
[INFO] openHAB Add-ons :: Bundles :: Chromecast Binding ... SUCCESS [ 56.020 s]
[INFO] openHAB Add-ons :: Bundles :: IO :: Modbus Transport SUCCESS [ 41.393 s]
[INFO] openHAB Add-ons :: Bundles :: Netatmo Binding ...... SUCCESS [ 45.396 s]
[INFO] openHAB Add-ons :: Bundles :: Smartmeter Binding ... SUCCESS [ 55.726 s]
[INFO] openHAB Add-ons :: Bundles :: Tellstick Binding .... SUCCESS [ 36.847 s]
[INFO] openHAB Add-ons :: Bundles :: IO :: Homekit ........ SUCCESS [ 32.935 s]
[INFO] openHAB Add-ons :: Bundles :: IO :: Hue Emulation Service SUCCESS [01:11 min]
[INFO] openHAB Add-ons :: Bundles :: Persistence Service :: DynamoDB SUCCESS [ 50.583 s]
[INFO] openHAB Add-ons :: Bundles :: Persistence Service :: InfluxDB SUCCESS [ 44.463 s]
[INFO] openHAB Add-ons :: Bundles :: Persistence Service :: JDBC SUCCESS [ 44.501 s]
[INFO] openHAB Add-ons :: Bundles :: Persistence Service :: JPA SUCCESS [ 52.672 s]
[INFO] openHAB Add-ons :: Bundles :: Voice :: Mary Text-to-Speech SUCCESS [01:17 min]
[INFO] openHAB Add-ons :: Integration Tests :: Feed Binding Tests SUCCESS [02:46 min]
[INFO] openHAB Add-ons :: Integration Tests :: Nest Binding Tests SUCCESS [ 32.563 s]
[INFO] openHAB Add-ons :: Integration Tests :: Systeminfo Binding Tests SUCCESS [01:02 min]

It only takes 18'54'' if I skip checks and tests.

@wborn
Copy link
Member

wborn commented Oct 19, 2020

It was run from a Git Bash window.

It might cause Spotless to think you prefer Unix-like line endings while Git thinks you prefer DOS/Windows line endings.

See also the Spotless line endings documentation:

Git has opinions about line endings, and if Spotless and git disagree, then you're going to have a bad time.

The only increase in build times I have noticed is due to more add-ons having been merged recently.
I added some more options to the README that you can use to improve build times in #8767.

Try disabling feature verification and a parallel build, e.g.:

mvn clean install -DskipChecks=true -DskipTests=true -Dfeatures.verify.skip=true -Dspotless.check.skip=true -T 1C

With that it only takes ~1 minute to build all add-ons on my machine.

@lolodomo
Copy link
Contributor Author

The result (error) is the same if I use Windows PowerShell.

@rogierhofboer
Copy link
Contributor

rogierhofboer commented Oct 26, 2020

@wborn I think you are right about the line endings. It seems if you checkout .xml files with Linux \n file endings on Windows maven finds the file invalid (which I can imagine), but if you checkout with Windows line endings \r\n spotless does think the file has bad formatting.

If you let spotless allow Windows line endings on Windows (if this is possible, didn't check yet) and you commit them with Windows line endings, you have mixed Linux and Windows line endings in the repository, also the spotless checks of the buildserver will fail.
Still I think this is the best solution and if a Windows user commits files with the wrong line endings, the commits won't be merged until the line endings are 'correct' (i.e. Linux).

One way to have better control as project over line endings is to add a .gitattributes file to the project with:

* text=auto

and if needed specify which file need to be handled as text if autodetection fails:

*.xml text
*.java text

See also:
diffplug/spotless#35

I think .gitattributes should be added to the project and spotless should be to configured to lineEndings 'GIT_ATTRIBUTES'

@wborn
Copy link
Member

wborn commented Oct 26, 2020

Looks like the .gitattributes wasn't added when Spotless was activated on the master/main branch. We already have this file on the 2.5.x branch, see: https://github.com/openhab/openhab-addons/blob/2.5.x/.gitattributes
I'll create some PRs to add it to this branch and the other projects.

wborn added a commit to wborn/openhab-addons that referenced this issue Oct 26, 2020
Without this configuration there are issues with line endings on Windows.

See: openhab#8712

Signed-off-by: Wouter Born <github@maindrain.net>
wborn added a commit to wborn/openhab-core that referenced this issue Oct 26, 2020
Without this configuration there are Spotless issues with line endings on Windows.

See: openhab/openhab-addons#8712

Signed-off-by: Wouter Born <github@maindrain.net>
J-N-K pushed a commit that referenced this issue Oct 26, 2020
Without this configuration there are issues with line endings on Windows.

See: #8712

Signed-off-by: Wouter Born <github@maindrain.net>
wborn added a commit to wborn/openhab-webui that referenced this issue Oct 26, 2020
Without this configuration there are Spotless issues with line endings on Windows.

See: openhab/openhab-addons#8712

Signed-off-by: Wouter Born <github@maindrain.net>
wborn added a commit to wborn/static-code-analysis that referenced this issue Oct 26, 2020
Without this configuration there are Spotless issues with line endings on Windows.

See: openhab/openhab-addons#8712

Signed-off-by: Wouter Born <github@maindrain.net>
@rogierhofboer
Copy link
Contributor

rogierhofboer commented Oct 26, 2020

@wborn Thanks!
Note: I just learned GIT_ATTRIBUTES as line endings option is the default (and recommended) configuration for spotless.

@wborn
Copy link
Member

wborn commented Oct 26, 2020

I hope it also solves @lolodomo's issues. If you did not have them on the 2.5.x branch they should now be solved as well. :-)

@rogierhofboer
Copy link
Contributor

It solves the problem for me :)

@lolodomo
Copy link
Contributor Author

I updated my local repo but unfortunately I still have the same problem when I try to compile the main branch.

@rogierhofboer
Copy link
Contributor

Damn sorry @wborn.... @lolodomo is correct..
I've retried with a full clean checkout and build and it fails again (with .gitattributes added by hand for openhab-core).

If it did work on 2.5.9, what else is different?

@rogierhofboer
Copy link
Contributor

rogierhofboer commented Oct 26, 2020

I think I know what might go wrong.
openhab-core/tools/static-code-analysis/checkstyle/ruleset.properties defines:

checkstyle.headerCheck.content=^/\\*\\*$\\n^ \\* Copyright \\(c\\) {0}-{1} Contributors to the openHAB project$\\n^ \\*$\\n^ \\* See the NOTICE file\\(s\\) distributed with this work for additional$\\n^ \\* information.$\\n^ \\*$\\n^ \\* This program and the accompanying materials are made available under the$\\n^ \\* terms of the Eclipse Public License 2\\.0 which is available at$\\n^ \\* http://www.eclipse.org/legal/epl\\-2\\.0$\\n^ \\*$\\n^ \\* 

With explicit linux line endings...
This is also where I now get the error (which is different then before)

@wborn
Copy link
Member

wborn commented Oct 26, 2020

Perhaps there is one of the @openhab/add-ons-maintainers who uses Windows and can check if there are still Spotless issues on the main branch and what could fix them? I have no issues or easy ways to reproduce this on Ubuntu. 😉

@rogierhofboer
Copy link
Contributor

I don't think it is the openhab-core/tools/static-code-analysis/checkstyle/ruleset.properties
\n seems to work, changing it to \r\n gives pattern match errors. If addons do build I could check how they are configured.

cweitkamp pushed a commit to openhab/openhab-core that referenced this issue Oct 26, 2020
Without this configuration there are Spotless issues with line endings on Windows.

See: openhab/openhab-addons#8712

Signed-off-by: Wouter Born <github@maindrain.net>
@rogierhofboer
Copy link
Contributor

For some reason spotless seems to ignore .gitattributes on master.
I am lost why it is. Even setting the value to crlf instead of auto does not make stop complaining line endings should be \n only.

@wborn
Copy link
Member

wborn commented Oct 26, 2020

Try the main branch instead of master. The master branch is no longer used.

@rogierhofboer
Copy link
Contributor

rogierhofboer commented Oct 26, 2020

openhab-core still uses master
I know this issue is in openhab-addons, but the problem is also present on openhab-core.

kaikreuzer pushed a commit to openhab/openhab-webui that referenced this issue Oct 27, 2020
Without this configuration there are Spotless issues with line endings on Windows.

See: openhab/openhab-addons#8712

Signed-off-by: Wouter Born <github@maindrain.net>
kaikreuzer pushed a commit to openhab/static-code-analysis that referenced this issue Oct 27, 2020
Without this configuration there are Spotless issues with line endings on Windows.

See: openhab/openhab-addons#8712

Signed-off-by: Wouter Born <github@maindrain.net>
@mherwege mherwege removed the bug An unexpected problem or unintended behavior of an add-on label Oct 27, 2020
@rogierhofboer
Copy link
Contributor

diffplug/spotless#540 related?
Looking into it...

@J-N-K
Copy link
Member

J-N-K commented Oct 31, 2020

I get the same error (on Win 10) if I start from the root-POM. Building single projects with -pl works. The interesting thing is, that mvn clean install -rf :org.openhab.addons.reactor.bundles also works.

@lolodomo
Copy link
Contributor Author

I can confirm that build from inside a binding is working.
Problem is when you build from the repo root folder.

@J-N-K
Copy link
Member

J-N-K commented Dec 3, 2020

git config core.eol=crlf solves the problem. This is not a problem since autcrlf=true takes precendence and git's behaviour stays unchanged.

@nedtwigg
Copy link

You might want * text eol=native, see diffplug/spotless#540

nowaterman pushed a commit to nowaterman/openhab-addons that referenced this issue Jan 19, 2021
Without this configuration there are issues with line endings on Windows.

See: openhab#8712
boehan pushed a commit to boehan/openhab-addons that referenced this issue Apr 12, 2021
Without this configuration there are issues with line endings on Windows.

See: openhab#8712

Signed-off-by: Wouter Born <github@maindrain.net>
marcfischerboschio pushed a commit to marcfischerboschio/openHABaddon that referenced this issue Apr 20, 2022
Without this configuration there are issues with line endings on Windows.

See: openhab/openhab-addons#8712

Signed-off-by: Wouter Born <github@maindrain.net>
@hmerk
Copy link
Contributor

hmerk commented Jun 28, 2022

Is this still an open issue ?

@wborn
Copy link
Member

wborn commented Jun 28, 2022

For me it works fine on Windows using:

git config --global core.autocrlf false
git config --global core.eol crlf

@lolodomo
Copy link
Contributor Author

I have to test these settings.

@wborn
Copy link
Member

wborn commented Sep 20, 2022

If it works better we probably want to update the developer docs as well. Sometimes those .gitattributes changes end up in PRs by Windows contributors. 😕

@lolodomo
Copy link
Contributor Author

For me it works fine on Windows using:

git config --global core.autocrlf false
git config --global core.eol crlf

Tried and working. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants