Skip to content

Commit 1b2c449

Browse files
authored
Alert maven users to order significance of steps (#1459)
2 parents 2901edb + bd562c1 commit 1b2c449

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

plugin-maven/README.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,16 @@ To use it in your pom, just [add the Spotless dependency](https://search.maven.o
129129
Spotless consists of a list of formats (in the example above, `misc` and `java`), and each format has:
130130
- a `target` (the files to format), which you set with [`includes` and `excludes`](https://github.com/diffplug/spotless/blob/989abbecff4d8373c6111c1a98f359eadc532429/plugin-maven/src/main/java/com/diffplug/spotless/maven/FormatterFactory.java#L51-L55)
131131
- a list of `FormatterStep`, which are just `String -> String` functions, such as [`replace`](https://github.com/diffplug/spotless/blob/main/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Replace.java), [`replaceRegex`](https://github.com/diffplug/spotless/blob/main/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/ReplaceRegex.java), [`trimTrailingWhitespace`](https://github.com/diffplug/spotless/blob/main/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/TrimTrailingWhitespace.java), [`indent`](https://github.com/diffplug/spotless/blob/main/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Indent.java), [`prettier`](https://github.com/diffplug/spotless/blob/main/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java), [`eclipseWtp`](https://github.com/diffplug/spotless/blob/main/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/EclipseWtp.java), and [`licenseHeader`](https://github.com/diffplug/spotless/blob/main/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/LicenseHeader.java).
132-
132+
- **order matters**, and this is good! (More info [here](https://github.com/diffplug/spotless/blob/main/PADDEDCELL.md) and [here](https://github.com/diffplug/spotless/blob/main/CONTRIBUTING.md#how-spotless-works))
133+
- For example, `googleJavaFormat` always indents with spaces, but some wish it had a tab mode
134+
- ```xml
135+
<googleJavaFormat/> // this works
136+
<indent><tabs>true</tabs><spacesPerTab>2</spacesPerTab></indent>
137+
```
138+
- ```xml
139+
<indent><tabs>true</tabs><spacesPerTab>2</spacesPerTab></indent>
140+
<googleJavaFormat/> // the tab indentation gets overwritten
141+
```
133142

134143
### Requirements
135144

@@ -179,6 +188,10 @@ any other maven phase (i.e. compile) then it can be configured as below;
179188
<include>src/test/java/**/*.java</include>
180189
</includes>
181190

191+
<googleJavaFormat /> <!-- has its own section below -->
192+
<eclipse /> <!-- has its own section below -->
193+
<prettier /> <!-- has its own section below -->
194+
182195
<importOrder /> <!-- standard import order -->
183196
<importOrder> <!-- or a custom ordering -->
184197
<wildcardsLast>false</wildcardsLast> <!-- Optional, default false. Sort wildcard import after specific imports -->
@@ -188,10 +201,6 @@ any other maven phase (i.e. compile) then it can be configured as below;
188201

189202
<removeUnusedImports /> <!-- self-explanatory -->
190203

191-
<googleJavaFormat /> <!-- has its own section below -->
192-
<eclipse /> <!-- has its own section below -->
193-
<prettier /> <!-- has its own section below -->
194-
195204
<formatAnnotations /> <!-- fixes formatting of type annotations, see below -->
196205

197206
<licenseHeader>

0 commit comments

Comments
 (0)