Repository navigation
Conversation
The "Can I apply Spotless to specific files?" section documented -PspotlessFiles, but the Gradle plugin does not read that property: it was deprecated in 4.3.0 and removed with the other deprecated options in 5.0.0, and only the Maven plugin still has it. Point to -PspotlessIdeHook, which takes a comma-separated list of absolute paths, and to ratchetFrom for formatting only changed files. Fixes diffplug#3183
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3183
I started from #3183 and checked it against the code. The Gradle README section "Can I apply Spotless to specific files?" (added in #2575, adapted from the Maven README) documents
gradle spotlessApply -PspotlessFiles=....spotlessFilesdoes not appear anywhere inplugin-gradle/src/mainexcept a javadoc note inFormatExtension.createIndependentApplyTaskLazy; onlyplugin-mavenreads it (AbstractSpotlessMojo). On the Gradle side it was deprecated in 4.3.0 and went away with the other deprecated options in 5.0.0 (#640), perplugin-gradle/CHANGES.md. So the documented command formats the whole target.This changes the section to say that, and points to what the Gradle plugin does have:
-PspotlessIdeHookwith a comma-separated list of absolute paths (IdeHook.Statesplits on,, andperformHookrequires absolute paths and skips files outside the target), as described inIDE_HOOK.md;ratchetFromfor formatting only the files changed on a branch.The section heading and anchor are unchanged, so the table of contents link still works. I added a line under
[Unreleased]/Fixedinplugin-gradle/CHANGES.md.How I found it
I searched
plugin-gradleforspotlessFilesand found only the README and the javadoc note, then readplugin-gradle/CHANGES.mdfor when it was deprecated and removed, andIdeHook.javato check what the replacement accepts.Where this can show up in practice
Someone who follows the README to format a few files, for example from a pre-commit hook or a script that passes the changed files, gets every file in the target formatted instead, which can touch many unrelated files in one commit. This is my estimate beyond the report in #3183.
Testing
IdeHook.javaandIDE_HOOK.md.-PspotlessIdeHook, andspotlessCheckon the Markdown files.