Skip to content

Commit f9dd7be

Browse files
Enable Gradle users to create steps that require a provisioner
1 parent d245b60 commit f9dd7be

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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)