Repository navigation
Investigate git-diff windows line ending issues in Spotless 7.0+ #2404
Description
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?
Activity
nedtwigg commentedon Jan 17, 2025
I bet it is related to line endings. Could be that somebody's local git config is messed up, could be a bug in JGit or Spotless's integration with it is. We did make a change around how the system .gitconfig gets loaded by Spotless.
The PR you linked is a very useful potential reproducer... I don't have time to dig in deeply right now, but my first thoughts are
leeturner commentedon Jan 17, 2025
Just trying to find some other examples. This run was from a dependabot dependency update:
https://github.com/wiremock/wiremock/actions/runs/12781384145
You can see that the latest run passed all the checks (java 11 & 17 across all OS's). What is interesting is that the latest run was the second run because the first run failed:
https://github.com/wiremock/wiremock/actions/runs/12781384145/attempts/1
The first run failed with the following errors (two jobs failed - both java 17 on windows):
So it isn't always consistent between multiple runs of the same PR.
Once we got all the jobs to pass on that second run, we merged the PR into main. The build and test on the main branch then failed but only one of the jobs failed that time (still one of the java 17 on windows):
https://github.com/wiremock/wiremock/actions/runs/12791234461
The error on the main build was:
Drop to the version of spotless where we didn't have any issues
lehmanju commentedon Mar 7, 2025
Same issue, if it fails, rerunning usually fixes it.
zml2008 commentedon Jun 15, 2025
I've experienced this issue pretty consistently since spotless 6.22.0 (6.21.0 was fine). What has made it more difficult to track down is that any local builds I try on windows machines work fine, but CI builds (in GHA) fail. Maybe that helps narrow things down?
I've tried to figure out what differences there might be in the environments, but without any luck so far unfortunately.
(quick edit: after some mucking around in a PR, i think i've isolated the issue to #1837)
fix(plugin-gradle): Try to locate the git system config without execu…
fix(plugin-gradle): Try to locate the git system config without execu…
Drop to the version of spotless where we didn't have any issues
[SPARK-53988] Upgrade `Spotless` to 8.0.0