Skip to content

Commit c8d13b1

Browse files
committed
MIscellaneous cleanup.
1 parent 998f188 commit c8d13b1

File tree

7 files changed

+9
-15
lines changed

7 files changed

+9
-15
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public void visitFile(FileVisitDetails fileVisitDetails) {
116116
void init(SpotlessTaskImpl impl) {
117117
super.init(impl);
118118
getProjectPath().set(getProject().getPath());
119+
getEncoding().set(impl.getEncoding());
119120
}
120121

121122
private String getTaskPathPrefix() {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,9 @@ protected void createFormatTasks(String name, FormatExtension formatExtension) {
112112

113113
TaskProvider<SpotlessCheck> checkTask = tasks.register(taskName + CHECK, SpotlessCheck.class, task -> {
114114
SpotlessTaskImpl source = spotlessTask.get();
115-
task.init(spotlessTask.get());
116-
task.getEncoding().set(source.getEncoding());
115+
task.init(source);
117116
task.setEnabled(!isIdeHook);
118-
task.dependsOn(spotlessTask);
117+
task.dependsOn(source);
119118

120119
// if the user runs both, make sure that apply happens first,
121120
task.mustRunAfter(applyTask);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
@CacheableTask
4343
public abstract class SpotlessTaskImpl extends SpotlessTask {
4444
@Internal
45-
abstract Property<SpotlessTaskService> getTakService();
45+
abstract Property<SpotlessTaskService> getTaskService();
4646

4747
@Internal
4848
abstract DirectoryProperty getProjectDir();
4949

5050
void init(Provider<SpotlessTaskService> service) {
51-
getTakService().set(service);
51+
getTaskService().set(service);
5252
getProjectDir().set(getProject().getProjectDir());
5353
}
5454

@@ -57,7 +57,7 @@ void init(Provider<SpotlessTaskService> service) {
5757

5858
@TaskAction
5959
public void performAction(InputChanges inputs) throws Exception {
60-
getTakService().get().registerSourceAlreadyRan(this);
60+
getTaskService().get().registerSourceAlreadyRan(this);
6161
if (target == null) {
6262
throw new GradleException("You must specify 'Iterable<File> target'");
6363
}
@@ -122,7 +122,7 @@ private File getOutputFile(File input) {
122122
String outputFileName = FormatExtension.relativize(projectDir, input);
123123
if (outputFileName == null) {
124124
throw new IllegalArgumentException(StringPrinter.buildString(printer -> {
125-
printer.println("Spotless error! All target files must be within the project root.");
125+
printer.println("Spotless error! All target files must be within the project dir.");
126126
printer.println(" project dir: " + projectDir.getAbsolutePath());
127127
printer.println(" target: " + input.getAbsolutePath());
128128
}));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static abstract class ClientTask extends DefaultTask {
6868

6969
void init(SpotlessTaskImpl impl) {
7070
getSpotlessOutDirectory().set(impl.getOutputDirectory());
71-
getTaskService().set(impl.getTakService());
71+
getTaskService().set(impl.getTaskService());
7272
getProjectDir().set(impl.getProjectDir());
7373
}
7474

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/DiffMessageFormatterTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import java.io.File;
1919
import java.io.IOException;
20-
import java.nio.charset.StandardCharsets;
2120
import java.util.ArrayList;
2221
import java.util.Arrays;
2322
import java.util.Collections;
@@ -71,7 +70,6 @@ private SpotlessTaskImpl createFormatTask(String name) {
7170
private SpotlessCheck createCheckTask(String name, SpotlessTaskImpl source) {
7271
SpotlessCheck task = project.getTasks().create("spotless" + SpotlessPlugin.capitalize(name) + "Check", SpotlessCheck.class);
7372
task.init(source);
74-
task.getEncoding().set(StandardCharsets.UTF_8.name());
7573
return task;
7674
}
7775

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GradleIncrementalResolutionTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import org.assertj.core.api.AbstractStringAssert;
2828
import org.assertj.core.api.Assertions;
29-
import org.gradle.testkit.runner.BuildResult;
3029
import org.junit.jupiter.api.Test;
3130

3231
import com.diffplug.common.base.Errors;
@@ -137,8 +136,7 @@ private String taskRanAgainst(String task, String... ranAgainst) throws IOExcept
137136
String console = StringPrinter.buildString(Errors.rethrow().wrap(printer -> {
138137
boolean expectFailure = task.equals("spotlessCheck") && !isClean();
139138
if (expectFailure) {
140-
BuildResult b = gradleRunner().withArguments(task, "--stacktrace").forwardStdOutput(printer.toWriter()).forwardStdError(printer.toWriter()).buildAndFail();
141-
// System.err.println(b.getOutput());
139+
gradleRunner().withArguments(task).forwardStdOutput(printer.toWriter()).forwardStdError(printer.toWriter()).buildAndFail();
142140
} else {
143141
gradleRunner().withArguments(task).forwardStdOutput(printer.toWriter()).build();
144142
}

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/PaddedCellTaskTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import java.io.File;
2121
import java.io.IOException;
22-
import java.nio.charset.StandardCharsets;
2322
import java.util.Arrays;
2423
import java.util.Collections;
2524

@@ -75,7 +74,6 @@ private SpotlessTaskImpl createFormatTask(String name, FormatterStep step) {
7574
private SpotlessCheck createCheckTask(String name, SpotlessTaskImpl source) {
7675
SpotlessCheck task = project.getTasks().create("spotless" + SpotlessPlugin.capitalize(name) + "Check", SpotlessCheck.class);
7776
task.init(source);
78-
task.getEncoding().set(StandardCharsets.UTF_8.name());
7977
return task;
8078
}
8179

0 commit comments

Comments
 (0)