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
Copy file name to clipboardExpand all lines: CHANGES.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,30 @@ This document is intended for Spotless developers.
10
10
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
11
11
12
12
## [Unreleased]
13
+
### Added
14
+
*`FileSignature.Promised` and `JarState.Promised` to facilitate round-trip serialization for the Gradle configuration cache. ([#1945](https://github.com/diffplug/spotless/pull/1945))
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
19
+
20
+
## [2.45.0] - 2024-01-23
21
+
### Added
22
+
* Support for `gofmt` ([#2001](https://github.com/diffplug/spotless/pull/2001))
23
+
* Support for formatting Java Docs for the Palantir formatter ([#2009](https://github.com/diffplug/spotless/pull/2009))
24
+
25
+
## [2.44.0] - 2024-01-15
26
+
### Added
27
+
* New static method to `DiffMessageFormatter` which allows to retrieve diffs with their line numbers ([#1960](https://github.com/diffplug/spotless/issues/1960))
28
+
* Gradle - Support for formatting shell scripts via [shfmt](https://github.com/mvdan/sh). ([#1994](https://github.com/diffplug/spotless/pull/1994))
29
+
### Fixed
30
+
* Fix empty files with biome >= 1.5.0 when formatting files that are in the ignore list of the biome configuration file. ([#1989](https://github.com/diffplug/spotless/pull/1989) fixes [#1987](https://github.com/diffplug/spotless/issues/1987))
31
+
* Fix a regression in BufStep where the same arguments were being provided to every `buf` invocation. ([#1976](https://github.com/diffplug/spotless/issues/1976))
32
+
### Changes
33
+
* Use palantir-java-format 2.39.0 on Java 21. ([#1948](https://github.com/diffplug/spotless/pull/1948))
34
+
* Bump default `ktlint` version to latest `1.0.1` -> `1.1.1`. ([#1973](https://github.com/diffplug/spotless/pull/1973))
35
+
* Bump default `googleJavaFormat` version to latest `1.18.1` -> `1.19.2`. ([#1971](https://github.com/diffplug/spotless/pull/1971))
36
+
* Bump default `diktat` version to latest `1.2.5` -> `2.0.0`. ([#1972](https://github.com/diffplug/spotless/pull/1972))
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+53-20Lines changed: 53 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,6 @@ For the folders below in monospace text, they are published on MavenCentral at t
36
36
|`lib-extra`| Contains the optional parts of Spotless which require external dependencies. `LineEnding.GIT_ATTRIBUTES` won't work unless `lib-extra` is available. |
37
37
|`plugin-gradle`| Integrates spotless and all of its formatters into Gradle. |
38
38
|`plugin-maven`| Integrates spotless and all of its formatters into Maven. |
39
-
| `_ext` | Folder for generating glue jars (specifically packaging Eclipse jars from p2 for consumption using maven).
40
39
41
40
## How to add a new FormatterStep
42
41
@@ -95,10 +94,31 @@ Here's a checklist for creating a new step for Spotless:
95
94
96
95
-[ ] Class name ends in Step, `SomeNewStep`.
97
96
-[ ] Class has a public static method named `create` that returns a `FormatterStep`.
98
-
-[ ] Has a test class named `SomeNewStepTest`.
97
+
-[ ] Has a test class named `SomeNewStepTest` that uses `StepHarness` or `StepHarnessWithFile` to test the step.
98
+
-[ ] Start with `StepHarness.forStep(myStep).supportsRoundTrip(false)`, and then add round trip support as described in the next section.
99
99
-[ ] Test class has test methods to verify behavior.
100
100
-[ ] Test class has a test method `equality()` which tests equality using `StepEqualityTester` (see existing methods for examples).
101
101
102
+
### Serialization roundtrip
103
+
104
+
In order to support Gradle's configuration cache, all `FormatterStep` must be round-trip serializable. This is a bit tricky because step equality is based on the serialized form of the state, and `transient` is used to take absolute paths out of the equality check. To make this work, roundtrip compatible steps actually have *two* states:
105
+
106
+
-`RoundtripState` which must be roundtrip serializable but has no equality constraints
107
+
-`FileSignature.Promised` for settings files and `JarState.Promised` for the classpath
108
+
-`EqualityState` which will never be reserialized and its serialized form is used for equality / hashCode checks
109
+
-`FileSignature` for settings files and `JarState` for the classpath
### Third-party dependencies via reflection or compile-only source sets
103
123
104
124
Most formatters are going to use some kind of third-party jar. Spotless integrates with many formatters, some of which have incompatible transitive dependencies. To address this, we resolve third-party dependencies using [`JarState`](https://github.com/diffplug/spotless/blob/b26f0972b185995d7c6a7aefa726c146d24d9a82/lib/src/main/java/com/diffplug/spotless/kotlin/KtfmtStep.java#L118). To call methods on the classes in that `JarState`, you can either use reflection or a compile-only source set. See [#524](https://github.com/diffplug/spotless/issues/524) for examples of both approaches.
@@ -119,24 +139,6 @@ There are many great formatters (prettier, clang-format, black, etc.) which live
119
139
120
140
Because of Spotless' up-to-date checking and [git ratcheting](https://github.com/diffplug/spotless/tree/main/plugin-gradle#ratchet), Spotless actually doesn't have to call formatters very often, so even an expensive shell call for every single invocation isn't that bad. Anything that works is better than nothing, and we can always speed things up later if it feels too slow (but it probably won't).
121
141
122
-
## How to enable the `_ext` projects
123
-
124
-
The `_ext` projects are disabled per default, since:
125
-
126
-
* some of the projects perform vast downloads at configuration time
127
-
* the downloaded content may change on server side and break CI builds
128
-
129
-
130
-
The `_ext` can be activated via the root project property `com.diffplug.spotless.include.ext`.
131
-
132
-
Activate the property via command line, like for example:
* Returns a git-style diff between the two unix strings.
266
+
* Returns a map entry with value being a git-style diff between the two unix strings and key being the 0-based line of the first difference (in the dirty string)
252
267
* <p>
253
268
* Output has no trailing newlines.
254
269
* <p>
255
270
* Boolean args determine whether whitespace or line endings will be visible.
0 commit comments