-
Notifications
You must be signed in to change notification settings - Fork 458
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
Gradle clean spotlessCheck fails when using prettier #651
Comments
Interesting, thanks for reporting! As a workaround, if you do @simschla no obligation, just fyi. |
That is pretty odd. @nedtwigg Is is possible that spotless invokes the |
Clean should always run before all of the formatting tasks: spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessExtensionImpl.java Lines 67 to 75 in 43e4e97
And the close call hierarchy looks like this:
spotless/lib/src/main/java/com/diffplug/spotless/Formatter.java Lines 280 to 286 in 43e4e97
spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessTaskImpl.java Lines 49 to 60 in 43e4e97
I have another guess though, I'll put it in the next comment. |
The FormatterStep has a "state", and a I think the up-to-date check happens before the clean task runs. So if the state constructor puts anything int the build directory, it will be wiped out. And it looks like it does put some things into the build directory: spotless/lib/src/main/java/com/diffplug/spotless/npm/NpmFormatterStepStateBase.java Lines 59 to 79 in 43e4e97
The solution would be for the State to describe these files, but not actually write them to disk. And then the It's a bit tricky to fix, but not terrible :) |
I see, changing things this way is a bit of work, but should be pretty doable. What the working theory cannot explain, however, is why |
Good catch @simschla, I forgot that detail, but I think it turns out to strengthen the case for the diagnosis above. spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java Lines 83 to 88 in 43e4e97
So the behavior that I would expect is:
which I think is consistent with the original report. |
In my own builds, I have started seeing this on |
I've started a PR (#657) trying to fix the issue, however, the problem does not appear to be that the steps are writing to the build dir. Your expected behavior for
It does not appear to be recreating the formatter but instead uses the (already cleaned up) formatter from |
Fixed in |
If you are submitting a bug, please include the following:
connection refused
exception when runninggradle clean spotlessCheck
.When I run
gradle clean spotlessCheck
it will fail, and if I continue withgradle spotlessCheck
(this is withoutclean
) it succeeds.When I run
gradle clean spotlessApply
it succeeds without errors.It seems when I run
gradle clean spotlessCheck
:tast :spotlessJava
has no problems, then prettier server is shutdowntask :spotlessJavaCheck
tries to connect to the prettier server and fails.gradle clean spotlessCheck --stacktrace
:The text was updated successfully, but these errors were encountered: