diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 27c78dde65..eaeb890734 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -9,6 +9,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Changes - `SpotlessApply` now only reports that it did work (and is otherwise `UP-TO-DATE`) when it actually rewrote a file. ([#2715](https://github.com/diffplug/spotless/issues/2715)) ### Fixed +- The README section "Can I apply Spotless to specific files?" no longer documents `-PspotlessFiles`, which the Gradle plugin does not read; it points to `-PspotlessIdeHook` and `ratchetFrom` instead. ([#3183](https://github.com/diffplug/spotless/issues/3183)) - GrEclipse no longer leaves a `file%3A...` directory in the working directory. ([#2019](https://github.com/diffplug/spotless/issues/2019)) - DBeaver SQL formatter no longer prints an `IndexOutOfBoundsException` when a file starts with a keyword like `SET`. ([#1552](https://github.com/diffplug/spotless/issues/1552)) - `expandWildcardImports()` no longer fails with `Symbol resolution not configured` on records and other syntax newer than Java 11, and leaves files JavaParser cannot validate unchanged. ([#2946](https://github.com/diffplug/spotless/issues/2946)) diff --git a/plugin-gradle/README.md b/plugin-gradle/README.md index e762f1d5c5..e0e4b3178c 100644 --- a/plugin-gradle/README.md +++ b/plugin-gradle/README.md @@ -2165,13 +2165,13 @@ tasks.withType(com.diffplug.gradle.spotless.SpotlessApply).configureEach { ## Can I apply Spotless to specific files? -You can target specific files by setting the `spotlessFiles` project property to a comma-separated list of file patterns: +The Gradle plugin does not read a `spotlessFiles` property like the Maven plugin does (`-PspotlessFiles` was deprecated in `4.3.0` and removed in `5.0.0`). To format one or a few files, pass their absolute paths to the [IDE hook](IDE_HOOK.md) as a comma-separated list: ``` -cmd> gradle spotlessApply -PspotlessFiles=my/file/pattern.java,more/generic/.*-pattern.java +cmd> gradle spotlessApply -PspotlessIdeHook=/abs/path/to/A.java,/abs/path/to/B.java ``` -The patterns are matched using `String#matches(String)` against the absolute file path. +In this mode `spotlessCheck` is disabled, and `spotlessApply` formats only the listed files that are part of a target. To limit formatting to the files changed on a branch, use [`ratchetFrom`](#ratchet).