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

Spotless complains about line endings on Windows with core.autocrlf=false #437

Closed
rweisleder opened this issue Sep 27, 2020 · 2 comments
Closed

Comments

@rweisleder
Copy link
Contributor

Extracted this issue from PR #427, see also the discussion on that PR...

The ArchUnit build gradlew build fails currently on my Windows machine:

Execution failed for task ':archunit:spotlessJavaCheck'.
> The following files had format violations:
      archunit\src\jdk9main\java\com\tngtech\archunit\core\domain\Java9DomainPlugin.java
          @@ -1,36 +1,36 @@
          -/*\n
          - * Copyright 2014-2020 TNG Technology Consulting GmbH\n
          - *\n
...
          +/*\r\n
          + * Copyright 2014-2020 TNG Technology Consulting GmbH\r\n
          + *\r\n
...
      ... (24 more lines that didn't fit)
  Violations also present in 662 other files.
  Run 'gradlew.bat :archunit:spotlessApply' to fix these violations.

Spotless wants to change the line endings of all files in my working copy from \n to \r\n.

My Git is configured to core.autocrlf=false, so the line endings in my working copy are \n.

Creating a .gitattributes file with the content

*.java text eol=lf

worked for me, but failed on GitHub's Windows runner, see https://github.com/TNG/ArchUnit/runs/1166974355

Execution failed for task ':archunit-junit4:spotlessJavaCheck'.
> The following files had format violations:
      archunit-junit\junit4\src\main\java\com\tngtech\archunit\junit\AnalyzeClasses.java
          @@ -1,18 +1,18 @@
          -/*\r\n
          - * Copyright 2014-2020 TNG Technology Consulting GmbH\r\n
          - *\r\n
...
          +/*\n
          + * Copyright 2014-2020 TNG Technology Consulting GmbH\n
          + *\n
...

In this case, Spotless wants to change the line endings from \r\n to \n.

Spotless has an issue for this topic which is not resolved currently: diffplug/spotless#540

@stefanroeck
Copy link

I ran into the same issue, .gitattributes did the trick as mentioned above.
After that, the JavaClassDescriptorTest fails due to an encoding issue which can be fixed by adding these lines to build.gradle:

    compileJava.options.encoding = "UTF-8"
    compileTestJava.options.encoding = "UTF-8"

@rweisleder
Copy link
Contributor Author

The issue diffplug/spotless#540 is fixed with Spotless 6.2.1. So this issue should be fixed by merging #782. (or a follow-up PR if dependabot is faster)

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

3 participants