spotless: ignoreErrorForPath does not work, perhaps related to build folder

I have supplied a path src/main/org/x/y/z/ExcludedFile.java to the ignoreErrorForPath method and the file still causes the build to fail. I’ve tried both Unix and Windows style paths.

Spotless 3.8.0 Gradle 4.5 Eclipse formatter

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 17 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks very much for this issue, @thc202 and @magneticflux.

This does not seem to be a bug but a misconception on what ignoreErrorForPath is used to.

You are correct, and this misconception is so deep that I didn’t realize you were right until I finally sat down to try to actually fix the bug. I considered attempting to resolve this by making ignoreErrorForPath do the obvious behavior, which is to ignore formatting errors on that path, but that turned out to be quite hacky. “Which files to format” and “which internal errors to suppress” are different questions, and mushing them together was ugly.

I think this whole issue is actually a symptom of our users didn’t have an easy way to exclude a file from formatting. We told people “if you want to ignore a folder, set target to be everything except that one file”. But that would be quite onerous for the examples given in this issue. I’m attempting to resolve this by adding a targetExclude parameter in PR #353.

If you’ve got a file that you’d like to be formatted, but for whatever reason it sometimes causes the third-party formatter to throw exceptions and you don’t want them to block your build then use ignoreErrorForPath. If you don’t want the file to be formatted in the first place, use targetExclude. I’m gonna close this out, please leave feedback in PR #353.