Skip to content

Commit 269b90a

Browse files
committed
Merge remote-tracking branch 'upstream/main' into issue-1741-ktlint-update-0.50.0
# Conflicts: # plugin-gradle/CHANGES.md
2 parents 1353723 + b27632e commit 269b90a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

plugin-gradle/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
77
* Bump default `ktlint` version to latest `0.49.1` -> `0.50.0`. ([#1741](https://github.com/diffplug/spotless/issues/1741))
88
* Dropped support for `ktlint 0.47.x` following our policy of supporting two breaking changes at a time.
99
* Dropped support for deprecated `useExperimental` parameter in favor of the `ktlint_experimental` property.
10+
* Add an overload for `FormatExtension.addStep` which provides access to the `FormatExtension`'s `Provisioner`, enabling custom steps to make use of third-party dependencies.
1011
### Fixed
1112
* Correctly support the syntax
1213
```

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.Random;
3131
import java.util.TreeMap;
3232
import java.util.function.Consumer;
33+
import java.util.function.Function;
3334

3435
import javax.annotation.Nullable;
3536
import javax.inject.Inject;
@@ -300,6 +301,13 @@ public void addStep(FormatterStep newStep) {
300301
steps.add(newStep);
301302
}
302303

304+
/** Adds a new step that requires a Provisioner. */
305+
public void addStep(Function<Provisioner, FormatterStep> createStepFn) {
306+
requireNonNull(createStepFn);
307+
FormatterStep newStep = createStepFn.apply(provisioner());
308+
addStep(newStep);
309+
}
310+
303311
/** Returns the index of the existing step with the given name, or -1 if no such step exists. */
304312
protected int getExistingStepIdx(String stepName) {
305313
for (int i = 0; i < steps.size(); ++i) {

0 commit comments

Comments
 (0)