You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To document one: I was able to parse the patterns from .gitignore using gradle-node-plugin and gitignore-to-glob-cli and apply them to the targetExclude option:
It's opt-in and works in both plugins, globally or per format:
Gradle: spotless { respectGitignore() }
Maven: <respectGitignore>true</respectGitignore>
A file is skipped using the same rules as git status: it matches any .gitignore (including nested ones and negations), .git/info/exclude or core.excludesFile, and it isn't tracked. Tracked files are still formatted even if they match a pattern, so nothing committed silently drops out of formatting. On Gradle it also works with the configuration cache.
Feedback is very welcome, especially on:
the name (respectGitignore vs. something like excludeGitIgnored)
whether tracked-but-ignored files should keep being formatted (current behaviour, same as git)
whether it should eventually become the default
If you get a chance to try it on a real project, I'd love to hear how it goes. Thanks!
Activity
tommy-mitchell commentedon Sep 29, 2026
To document one: I was able to parse the patterns from
.gitignoreusinggradle-node-pluginandgitignore-to-glob-cliand apply them to thetargetExcludeoption:Pankraz76 commentedon Nov 8, 2026
Thanks @ivandimitrov8080 for the suggestion, and @tommy-mitchell for sharing the workaround. It made the use case very concrete!
I've opened a draft PR that adds this: #3176
It's opt-in and works in both plugins, globally or per format:
spotless { respectGitignore() }<respectGitignore>true</respectGitignore>A file is skipped using the same rules as
git status: it matches any.gitignore(including nested ones and negations),.git/info/excludeorcore.excludesFile, and it isn't tracked. Tracked files are still formatted even if they match a pattern, so nothing committed silently drops out of formatting. On Gradle it also works with the configuration cache.Feedback is very welcome, especially on:
respectGitignorevs. something likeexcludeGitIgnored)If you get a chance to try it on a real project, I'd love to hear how it goes. Thanks!