Skip to content

Commit b331249

Browse files
authored
Merge branch 'diffplug:main' into fix-RemoveWildcardImportsStep
2 parents c0cf2da + ff973d3 commit b331249

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

plugin-gradle/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Spotless supports all of Gradle's built-in performance features (incremental bui
9292
- [Disabling warnings and error messages](#disabling-warnings-and-error-messages)
9393
- [Dependency resolution modes](#dependency-resolution-modes)
9494
- [How do I preview what `spotlessApply` will do?](#how-do-i-preview-what-spotlessapply-will-do)
95+
- [Can I apply Spotless to specific files?](#can-i-apply-spotless-to-specific-files)
9596
- [Example configurations (from real-world projects)](#example-configurations-from-real-world-projects)
9697

9798
***Contributions are welcome, see [the contributing guide](../CONTRIBUTING.md) for development info.***
@@ -1897,6 +1898,16 @@ If you use this feature, you will get an error if you use a formatter in a subpr
18971898
18981899
<a name="examples"></a>
18991900
1901+
## Can I apply Spotless to specific files?
1902+
1903+
You can target specific files by setting the `spotlessFiles` project property to a comma-separated list of file patterns:
1904+
1905+
```
1906+
cmd> gradle spotlessApply -PspotlessFiles=my/file/pattern.java,more/generic/.*-pattern.java
1907+
```
1908+
1909+
The patterns are matched using `String#matches(String)` against the absolute file path.
1910+
19001911
## Example configurations (from real-world projects)
19011912
19021913
* [A few thousand github projects](https://github.com/search?l=gradle&q=spotless&type=Code)

plugin-maven/IDE_HOOK.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Spotless Maven IDE integrations
2+
3+
## How to add an IDE
4+
5+
The Spotless plugin for Maven accepts a command-line argument `-DspotlessIdeHook=${ABSOLUTE_PATH_TO_FILE}`. In this mode, `spotless:check` is disabled, and `spotless:apply` will apply only to that one file. Because it already knows the absolute path of the only file you are asking about, it is able to run much faster than a normal invocation of `spotless:apply`.
6+
7+
For extra flexibility, you can add `-DspotlessIdeHookUseStdIn`, and Spotless will read the file content from `stdin`. This allows you to send the content of a dirty editor buffer without writing to a file. You can also add `-DspotlessIdeHookUseStdOut`, and Spotless will return the formatted content on `stdout` rather than writing it to a file (you should also add `--quiet` to make sure Maven doesn't dump logging info into `stdout`).
8+
9+
In all of these cases, Spotless will send useful status information on `stderr`:
10+
11+
- if `stderr` starts with `IS DIRTY`, then the file was dirty, and `stdout` contains its full formatted contents
12+
- in every other case, `stdout` will be empty / the file will be unchanged because there is nothing to change
13+
- if `stderr` starts with `IS CLEAN`, then the file is already clean
14+
- if `stderr` starts with `DID NOT CONVERGE`, then the formatter is misbehaving, and the rest of `stderr` has useful diagnostic info (e.g. `spotless:diagnose` for [padded cell](../PADDEDCELL.md))
15+
- if `stderr` is empty, then the file is not being formatted by spotless (not included in any target)
16+
- if `stderr` is anything else, then it is the stacktrace of whatever went wrong

0 commit comments

Comments
 (0)