Skip to content

Commit 5b16ed1

Browse files
committed
allow specification of path to exe
1 parent 4e56621 commit 5b16ed1

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public LicenseHeaderConfig licenseHeaderFile(Object licenseHeaderFile) {
4242
return licenseHeaderFile(licenseHeaderFile, LICENSE_HEADER_DELIMITER);
4343
}
4444

45+
/** If the user hasn't specified files, assume all protobuf files should be checked. */
46+
@Override
47+
protected void setupTask(SpotlessTask task) {
48+
if (target == null) {
49+
target = parseTarget("**/*.proto");
50+
}
51+
super.setupTask(task);
52+
}
53+
4554
/** Adds the specified version of <a href="https://buf.build/">buf</a>. */
4655
public BufFormatExtension buf(String version) {
4756
Objects.requireNonNull(version);
@@ -53,24 +62,21 @@ public BufFormatExtension buf() {
5362
}
5463

5564
public class BufFormatExtension {
56-
private final String version;
65+
BufStep step;
5766

5867
BufFormatExtension(String version) {
59-
this.version = version;
68+
this.step = BufStep.withVersion(version);
6069
addStep(createStep());
6170
}
6271

63-
private FormatterStep createStep() {
64-
return BufStep.withVersion(version).create();
72+
public BufFormatExtension pathToExe(String pathToExe) {
73+
step = step.withPathToExe(pathToExe);
74+
replaceStep(createStep());
75+
return this;
6576
}
66-
}
6777

68-
/** If the user hasn't specified files, assume all protobuf files should be checked. */
69-
@Override
70-
protected void setupTask(SpotlessTask task) {
71-
if (target == null) {
72-
target = parseTarget("**/*.proto");
78+
private FormatterStep createStep() {
79+
return step.create();
7380
}
74-
super.setupTask(task);
7581
}
7682
}

0 commit comments

Comments
 (0)