Skip to content

Investigate git-diff windows line ending issues in Spotless 7.0+ #2404

Open
@nedtwigg

Description

@nedtwigg

Discussed in #2403

Originally posted by leeturner January 17, 2025
Hi

We have used spotless for quite a while now on the WireMock project. We use it to format files in the project and apply a license header (with a year or year range) to source files that are new or have changed.

We have recently started to see builds fail due to spotless thinking some of our java files need the license header updated to have a 2025 year in the header. The strange thing is that the files that it is failing on haven't changed. I have even see the main build fail when the branch I just merged all passed. We are seeing the failures on our Windows java 17 builds (we build on java 11 and java 17 across mac os, ubuntu and windows)

You can see in this PR that only one file has changed but the build is failing. The failure is:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':wiremock-jetty12:spotlessJavaCheck'.
> The following files had format violations:
      src\test\java\com\github\tomakehurst\wiremock\jetty12\FaultsTest.java
          @@ -1,5 +1,5 @@
           /*
          -�*�Copyright�(C)�2024�Thomas�Akehurst
          +�*�Copyright�(C)�2024-2025�Thomas�Akehurst
           �*
           �*�Licensed�under�the�Apache�License,�Version�2.0�(the�"License");
           �*�you�may�not�use�this�file�except�in�compliance�with�the�License.
      src\test\java\com\github\tomakehurst\wiremock\jetty12\Http2AcceptanceTest.java
          @@ -1,5 +1,5 @@
           /*
          -�*�Copyright�(C)�2019-2024�Thomas�Akehurst
          +�*�Copyright�(C)�2019-2025�Thomas�Akehurst
           �*
           �*�Licensed�under�the�Apache�License,�Version�2.0�(the�"License");
           �*�you�may�not�use�this�file�except�in�compliance�with�the�License.
      src\test\java\com\github\tomakehurst\wiremock\jetty12\Http2ClientFactory.java
          @@ -1,5 +1,5 @@
           /*
          -�*�Copyright�(C)�2019-2024�Thomas�Akehurst
          +�*�Copyright�(C)�2019-2025�Thomas�Akehurst
           �*
           �*�Licensed�under�the�Apache�License,�Version�2.0�(the�"License");
           �*�you�may�not�use�this�file�except�in�compliance�with�the�License.
      src\test\java\com\github\tomakehurst\wiremock\jetty12\Http2DisabledAcceptanceTest.java
          @@ -1,5 +1,5 @@
           /*
          -�*�Copyright�(C)�2024�Thomas�Akehurst
          +�*�Copyright�(C)�2024-2025�Thomas�Akehurst
           �*
           �*�Licensed�under�the�Apache�License,�Version�2.0�(the�"License");
           �*�you�may�not�use�this�file�except�in�compliance�with�the�License.
      src\test\java\com\github\tomakehurst\wiremock\jetty12\Jetty12MultipartParser.java
          @@ -1,5 +1,5 @@
           /*
          -�*�Copyright�(C)�2018-2024�Thomas�Akehurst
          +�*�Copyright�(C)�2018-2025�Thomas�Akehurst
           �*
           �*�Licensed�under�the�Apache�License,�Version�2.0�(the�"License");
           �*�you�may�not�use�this�file�except�in�compliance�with�the�License.
      src\test\java\com\github\tomakehurst\wiremock\jetty12\Jetty12MultipartParserLoader.java
          @@ -1,5 +1,5 @@
           /*
          -�*�Copyright�(C)�2018-2024�Thomas�Akehurst
          +�*�Copyright�(C)�2018-2025�Thomas�Akehurst
           �*
           �*�Licensed�under�the�Apache�License,�Version�2.0�(the�"License");
           �*�you�may�not�use�this�file�except�in�compliance�with�the�License.
      src\test\java\com\github\tomakehurst\wiremock\jetty12\ProgrammaticHttpServerAcceptanceTest.java
          @@ -1,5 +1,5 @@
           /*
          -�*�Copyright�(C)�2019-2024�Thomas�Akehurst
      ... (4 more lines that didn't fit)
  Violations also present in:
      src\test\java\com\github\tomakehurst\wiremock\jetty12\server\CustomHttpServer.java
      src\test\java\com\github\tomakehurst\wiremock\jetty12\server\CustomHttpServerFactory.java
      src\test\java\com\github\tomakehurst\wiremock\jetty12\servlet\AlternativeServletContainerTest.java
      src\test\java\com\github\tomakehurst\wiremock\jetty12\servlet\AltHttpServerFactory.java
  Run 'gradlew.bat :wiremock-jetty12:spotlessApply' to fix these violations.

We have updated to the latest spotless recently (id 'com.diffplug.spotless' version '7.0.2') but I haven't yet correlated whether the issues started at the same time or not.

We use gradle for our builds with the following config:

  spotless {
    java {
      target 'src/**/*.java'
      googleJavaFormat('1.17.0')
      licenseHeaderFile "${rootDir}/gradle/spotless.java.license.txt"
      ratchetFrom 'origin/master'
      trimTrailingWhitespace()
      endWithNewline()
      targetExclude '**/Tmp*.java'
    }
    groovyGradle {
      target '**/*.gradle'
      greclipse()
      indentWithSpaces(2)
      trimTrailingWhitespace()
      endWithNewline()
    }
    json {
      target 'src/**/*.json'
      targetExclude '**/tmp*.json', 'src/test/resources/sample.json', 'src/main/resources/swagger/*.json', 'src/test/resources/filesource/subdir/deepfile.json', 'src/test/resources/schema-validation/*.json', 'src/test/resources/test-file-root/mappings/testjsonmapping.json', 'src/main/resources/assets/swagger-ui/swagger-ui-dist/package.json'
      simple().indentWithSpaces(2)
    }
  }

Is anyone else experiencing similar issues?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions