From 2c689773fca8c47ddb371ed21b0aab524f4b2c25 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 22 Jun 2020 16:08:05 -0700 Subject: [PATCH 01/13] Add a `subpath` routine to `FileSignature`. --- .../main/java/com/diffplug/spotless/FileSignature.java | 9 +++++++++ .../java/com/diffplug/spotless/FileSignatureTest.java | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/src/main/java/com/diffplug/spotless/FileSignature.java b/lib/src/main/java/com/diffplug/spotless/FileSignature.java index 0c0cb7a198..3628e96eab 100644 --- a/lib/src/main/java/com/diffplug/spotless/FileSignature.java +++ b/lib/src/main/java/com/diffplug/spotless/FileSignature.java @@ -119,4 +119,13 @@ public static String pathNativeToUnix(String pathNative) { public static String pathUnixToNative(String pathUnix) { return LineEnding.nativeIsWin() ? pathUnix.replace('/', '\\') : pathUnix; } + + /** Asserts that child is a subpath of root. and returns the subpath. */ + public static String subpath(String root, String child) { + if (child.startsWith(root)) { + return child.substring(root.length()); + } else { + throw new IllegalArgumentException("Expected '" + child + "' to start with '" + root + "'"); + } + } } diff --git a/testlib/src/test/java/com/diffplug/spotless/FileSignatureTest.java b/testlib/src/test/java/com/diffplug/spotless/FileSignatureTest.java index b514a764fb..aa217ac02d 100644 --- a/testlib/src/test/java/com/diffplug/spotless/FileSignatureTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/FileSignatureTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 DiffPlug + * Copyright 2016-2020 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,4 +56,8 @@ private List getTestFiles(final String[] paths) throws IOException { return result; } + @Test + public void testSubpath() { + assertThat(FileSignature.subpath("root/", "root/child")).isEqualTo("child"); + } } From 082f86718e44f791f31fbdc4a7858db78aab354f Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 22 Jun 2020 16:24:31 -0700 Subject: [PATCH 02/13] Add a new `GitAttributesLineEndings.Policy` which relativizes all paths against the projectDir, and does not rely on FileSignature at all. --- .../extra/GitAttributesLineEndings.java | 67 ++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java index 1816a3fa1b..1d3a46a2f1 100644 --- a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java +++ b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 DiffPlug + * Copyright 2016-2020 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,70 @@ public final class GitAttributesLineEndings { // prevent direct instantiation private GitAttributesLineEndings() {} - public static Policy create(File projectDir, Supplier> toFormat) { + /** + * Creates a line-endings policy whose serialized state is relativized against projectDir, + * at the cost of eagerly evaluating the line-ending state of every target file. + */ + public static LineEnding.Policy createRelocatable(File projectDir, Supplier> toFormat) { + return new RelocatablePolicy(projectDir, toFormat); + } + + static class RelocatablePolicy extends LazyForwardingEquality implements LineEnding.Policy { + private static final long serialVersionUID = 5868522122123693015L; + + final transient File projectDir; + final transient Supplier> toFormat; + + RelocatablePolicy(File projectDir, Supplier> toFormat) { + this.projectDir = Objects.requireNonNull(projectDir, "projectDir"); + this.toFormat = Objects.requireNonNull(toFormat, "toFormat"); + } + + @Override + protected CachedEndings calculateState() throws Exception { + Runtime runtime = new FileState(projectDir, toFormat.get()).atRuntime(); + return new CachedEndings(projectDir, runtime, toFormat.get()); + } + + @Override + public String getEndingFor(File file) { + return state().endingFor(file); + } + } + + static class CachedEndings implements Serializable { + private static final long serialVersionUID = -2534772773057900619L; + + /** this is transient, to simulate PathSensitive.RELATIVE */ + transient final String rootDir; + /** the line ending used for most files */ + final String defaultEnding; + /** any exceptions to that default, in terms of relative path from rootDir */ + final ConcurrentRadixTree hasNonDefaultEnding = new ConcurrentRadixTree<>(new DefaultCharSequenceNodeFactory()); + + CachedEndings(File projectDir, Runtime runtime, Iterable toFormat) { + rootDir = FileSignature.pathNativeToUnix(projectDir.getAbsolutePath()) + "/"; + defaultEnding = runtime.defaultEnding; + for (File file : toFormat) { + String ending = runtime.getEndingFor(file); + if (!ending.equals(defaultEnding)) { + String path = FileSignature.pathNativeToUnix(file.getAbsolutePath()); + hasNonDefaultEnding.put(path, ending); + } + } + } + + /** Returns the line ending appropriate for the given file. */ + public String endingFor(File file) { + String path = FileSignature.pathNativeToUnix(file.getAbsolutePath()); + String subpath = FileSignature.subpath(rootDir, path); + String ending = hasNonDefaultEnding.getValueForExactKey(subpath); + return ending == null ? defaultEnding : ending; + } + } + + /** Creates a line-endings policy whose serialized state includes absolute paths to this machine. */ + public static LineEnding.Policy create(File projectDir, Supplier> toFormat) { return new Policy(projectDir, toFormat); } From aab35d53a066b27292b50b69069c2970957f6bad Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 22 Jun 2020 16:26:54 -0700 Subject: [PATCH 03/13] Make the new policy the only policy. --- .../extra/GitAttributesLineEndings.java | 38 +------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java index 1d3a46a2f1..48db0860fc 100644 --- a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java +++ b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java @@ -76,7 +76,7 @@ private GitAttributesLineEndings() {} * Creates a line-endings policy whose serialized state is relativized against projectDir, * at the cost of eagerly evaluating the line-ending state of every target file. */ - public static LineEnding.Policy createRelocatable(File projectDir, Supplier> toFormat) { + public static LineEnding.Policy create(File projectDir, Supplier> toFormat) { return new RelocatablePolicy(projectDir, toFormat); } @@ -134,42 +134,6 @@ public String endingFor(File file) { } } - /** Creates a line-endings policy whose serialized state includes absolute paths to this machine. */ - public static LineEnding.Policy create(File projectDir, Supplier> toFormat) { - return new Policy(projectDir, toFormat); - } - - static class Policy extends LazyForwardingEquality implements LineEnding.Policy { - private static final long serialVersionUID = 1L; - - final transient File projectDir; - final transient Supplier> toFormat; - - Policy(File projectDir, Supplier> toFormat) { - this.projectDir = Objects.requireNonNull(projectDir, "projectDir"); - this.toFormat = Objects.requireNonNull(toFormat, "toFormat"); - } - - @Override - protected FileState calculateState() throws Exception { - return new FileState(projectDir, toFormat.get()); - } - - /** - * Initializing the state() for up-to-date checking is faster than the full initialization - * needed to actually do the formatting. We load the Runtime lazily from the state(). - */ - transient Runtime runtime; - - @Override - public String getEndingFor(File file) { - if (runtime == null) { - runtime = state().atRuntime(); - } - return runtime.getEndingFor(file); - } - } - @SuppressFBWarnings("SE_TRANSIENT_FIELD_NOT_RESTORED") static class FileState implements Serializable { private static final long serialVersionUID = 1L; From 29535603224b68fd504834cf5afbf1e4ba8bb0fe Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 22 Jun 2020 16:29:49 -0700 Subject: [PATCH 04/13] Now we don't need anything except `CachedEndings` to be `Serializable`. --- .../extra/GitAttributesLineEndings.java | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java index 48db0860fc..8020df2ef1 100644 --- a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java +++ b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java @@ -34,7 +34,6 @@ import java.util.Set; import java.util.function.Supplier; import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.annotation.Nullable; @@ -134,24 +133,18 @@ public String endingFor(File file) { } } - @SuppressFBWarnings("SE_TRANSIENT_FIELD_NOT_RESTORED") - static class FileState implements Serializable { - private static final long serialVersionUID = 1L; - + static class FileState { /** /etc/gitconfig (system-global), ~/.gitconfig, project/.git/config (each might-not exist). */ - transient final FileBasedConfig systemConfig, userConfig, repoConfig; + final FileBasedConfig systemConfig, userConfig, repoConfig; /** Global .gitattributes file pointed at by systemConfig or userConfig, and the file in the repo. */ - transient final @Nullable File globalAttributesFile, repoAttributesFile; + final @Nullable File globalAttributesFile, repoAttributesFile; /** git worktree root, might not exist if we're not in a git repo. */ - transient final @Nullable File workTree; + final @Nullable File workTree; /** All the .gitattributes files in the work tree that we're formatting. */ - transient final List gitattributes; - - /** The signature of *all* of the files below. */ - final FileSignature signature; + final List gitattributes; @SuppressFBWarnings("SIC_INNER_SHOULD_BE_STATIC_ANON") FileState(File projectDir, Iterable toFormat) throws IOException { @@ -208,14 +201,6 @@ public boolean isOutdated() { // The .gitattributes files which apply to the files we are formatting gitattributes = gitAttributes(toFormat); - - // find every actual File which exists above - Stream misc = Stream.of(systemConfig.getFile(), userConfig.getFile(), repoConfig.getFile(), globalAttributesFile, repoAttributesFile); - List toSign = Stream.concat(gitattributes.stream(), misc) - .filter(file -> file != null && file.exists() && file.isFile()) - .collect(Collectors.toList()); - // sign it for up-to-date checking - signature = FileSignature.signAsSet(toSign); } /** Returns all of the .gitattributes files which affect the given files. */ From 758414bc2b9acde11314c29dcf26b5eeb777e0c1 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 22 Jun 2020 16:34:47 -0700 Subject: [PATCH 05/13] Improve the javadoc. --- .../com/diffplug/spotless/extra/GitAttributesLineEndings.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java index 8020df2ef1..7d1b84fac1 100644 --- a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java +++ b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java @@ -73,7 +73,8 @@ private GitAttributesLineEndings() {} /** * Creates a line-endings policy whose serialized state is relativized against projectDir, - * at the cost of eagerly evaluating the line-ending state of every target file. + * at the cost of eagerly evaluating the line-ending state of every target file when the + * policy is checked for equality with another policy. */ public static LineEnding.Policy create(File projectDir, Supplier> toFormat) { return new RelocatablePolicy(projectDir, toFormat); From fdf2445022a1f49c10cb2990a3eeaa1aec381fa6 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 22 Jun 2020 16:46:24 -0700 Subject: [PATCH 06/13] Fix spotbugs warnings. --- .../extra/GitAttributesLineEndings.java | 53 +------------------ 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java index 7d1b84fac1..b0547353d9 100644 --- a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java +++ b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java @@ -22,18 +22,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; -import java.util.Set; import java.util.function.Supplier; -import java.util.stream.Collectors; import javax.annotation.Nullable; @@ -50,11 +45,9 @@ import org.eclipse.jgit.util.SystemReader; import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; -import com.googlecode.concurrenttrees.radix.node.Node; import com.googlecode.concurrenttrees.radix.node.concrete.DefaultCharSequenceNodeFactory; import com.diffplug.common.base.Errors; -import com.diffplug.common.tree.TreeStream; import com.diffplug.spotless.FileSignature; import com.diffplug.spotless.LazyForwardingEquality; import com.diffplug.spotless.LineEnding; @@ -103,6 +96,7 @@ public String getEndingFor(File file) { } } + @SuppressFBWarnings("SE_TRANSIENT_FIELD_NOT_RESTORED") static class CachedEndings implements Serializable { private static final long serialVersionUID = -2534772773057900619L; @@ -144,9 +138,6 @@ static class FileState { /** git worktree root, might not exist if we're not in a git repo. */ final @Nullable File workTree; - /** All the .gitattributes files in the work tree that we're formatting. */ - final List gitattributes; - @SuppressFBWarnings("SIC_INNER_SHOULD_BE_STATIC_ANON") FileState(File projectDir, Iterable toFormat) throws IOException { requireElementsNonNull(toFormat); @@ -199,48 +190,6 @@ public boolean isOutdated() { repoAttributesFile = null; } Errors.log().run(repoConfig::load); - - // The .gitattributes files which apply to the files we are formatting - gitattributes = gitAttributes(toFormat); - } - - /** Returns all of the .gitattributes files which affect the given files. */ - static List gitAttributes(Iterable files) { - // build a radix tree out of all the parent folders in these files - ConcurrentRadixTree tree = new ConcurrentRadixTree<>(new DefaultCharSequenceNodeFactory()); - for (File file : files) { - String parentPath = file.getParent() + File.separator; - tree.putIfAbsent(parentPath, parentPath); - } - // traverse the edge nodes to find the outermost folders - List edgeFolders = TreeStream.depthFirst(Node::getOutgoingEdges, tree.getNode()) - .filter(node -> node.getOutgoingEdges().isEmpty() && node.getValue() != null) - .map(node -> new File((String) node.getValue())) - .collect(Collectors.toList()); - - List gitAttrFiles = new ArrayList<>(); - Set visitedFolders = new HashSet<>(); - for (File edgeFolder : edgeFolders) { - gitAttrAddWithParents(edgeFolder, visitedFolders, gitAttrFiles); - } - return gitAttrFiles; - } - - /** Searches folder and all its parents for gitattributes files. */ - private static void gitAttrAddWithParents(File folder, Set visitedFolders, Collection gitAttrFiles) { - if (!visitedFolders.add(folder)) { - // bail if we already visited this folder - return; - } - - File gitAttr = new File(folder, Constants.DOT_GIT_ATTRIBUTES); - if (gitAttr.exists() && gitAttr.isFile()) { - gitAttrFiles.add(gitAttr); - } - File parentFile = folder.getParentFile(); - if (parentFile != null) { - gitAttrAddWithParents(folder.getParentFile(), visitedFolders, gitAttrFiles); - } } private Runtime atRuntime() { From 275c2a859f4e2db2c47d4dcb84a5af793625795c Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 22 Jun 2020 16:48:16 -0700 Subject: [PATCH 07/13] Rename `FileState` to `RuntimeInit`, since it no longer stores any state at all. --- .../diffplug/spotless/extra/GitAttributesLineEndings.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java index b0547353d9..630f4bacb4 100644 --- a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java +++ b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java @@ -86,7 +86,7 @@ static class RelocatablePolicy extends LazyForwardingEquality imp @Override protected CachedEndings calculateState() throws Exception { - Runtime runtime = new FileState(projectDir, toFormat.get()).atRuntime(); + Runtime runtime = new RuntimeInit(projectDir, toFormat.get()).atRuntime(); return new CachedEndings(projectDir, runtime, toFormat.get()); } @@ -128,7 +128,7 @@ public String endingFor(File file) { } } - static class FileState { + static class RuntimeInit { /** /etc/gitconfig (system-global), ~/.gitconfig, project/.git/config (each might-not exist). */ final FileBasedConfig systemConfig, userConfig, repoConfig; @@ -139,7 +139,7 @@ static class FileState { final @Nullable File workTree; @SuppressFBWarnings("SIC_INNER_SHOULD_BE_STATIC_ANON") - FileState(File projectDir, Iterable toFormat) throws IOException { + RuntimeInit(File projectDir, Iterable toFormat) throws IOException { requireElementsNonNull(toFormat); ///////////////////////////////// // USER AND SYSTEM-WIDE VALUES // From 244ead71f167b8b5634dc2831118e9e4f90deaa6 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 22 Jun 2020 17:40:54 -0700 Subject: [PATCH 08/13] Add changelog entry. --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index d8d3a90796..959e1c939f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,8 @@ This document is intended for Spotless developers. We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +### Changed +* `LineEnding.GIT_ATTRIBUTES` now creates a policy whose serialized state can be relocated from one machine to another. No user-visible change, but paves the way for remote build cache support in Gradle. ([#621](https://github.com/diffplug/spotless/pull/621)) ## [1.34.1] - 2020-06-17 ### Changed From 68d8b3b55bc88ee62f884f08837ec5df4279ddb8 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 27 Jun 2020 15:28:37 -0700 Subject: [PATCH 09/13] SpotlessTaskBase was setting a bogus lineEndingsPolicy. It would always be overwritten, but it still shouldn't be there. --- .../java/com/diffplug/gradle/spotless/SpotlessTaskBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessTaskBase.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessTaskBase.java index 4f768059c3..37e5a78341 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessTaskBase.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessTaskBase.java @@ -63,7 +63,7 @@ public void setEncoding(String encoding) { this.encoding = Objects.requireNonNull(encoding); } - protected LineEnding.Policy lineEndingsPolicy = LineEnding.UNIX.createPolicy(); + protected LineEnding.Policy lineEndingsPolicy; @Input public LineEnding.Policy getLineEndingsPolicy() { From 5e743b0416727b4fdb1d175911b0e09443e7dc14 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 27 Jun 2020 15:30:04 -0700 Subject: [PATCH 10/13] The line endings policy would previously have had to compute against more files than necessary, now fixed. --- .../com/diffplug/gradle/spotless/FormatExtension.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java index f3bf1a6673..3eb14d6a08 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java @@ -669,13 +669,10 @@ public EclipseWtpConfig eclipseWtp(EclipseWtpFormatterStep type, String version) protected void setupTask(SpotlessTask task) { task.setEncoding(getEncoding().name()); task.setExceptionPolicy(exceptionPolicy); - if (targetExclude == null) { - task.setTarget(target); - } else { - task.setTarget(target.minus(targetExclude)); - } + FileCollection totalTarget = targetExclude == null ? target : target.minus(targetExclude); + task.setTarget(totalTarget); task.setSteps(steps); - task.setLineEndingsPolicy(getLineEndings().createPolicy(getProject().getProjectDir(), () -> task.target)); + task.setLineEndingsPolicy(getLineEndings().createPolicy(getProject().getProjectDir(), () -> totalTarget)); if (spotless.project != spotless.project.getRootProject()) { spotless.getRegisterDependenciesTask().hookSubprojectTask(task); } From 083c724ea4d5bbeb2a4001eb812a1c509fa0b9c0 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 27 Jun 2020 15:33:07 -0700 Subject: [PATCH 11/13] Update changelog for plugin-gradle. --- plugin-gradle/CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index abcf56fedb..20d5a8203d 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -7,6 +7,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### Added * `prettier` will now autodetect the parser (and formatter) to use based on the filename, unless you override this using `config()` or `configFile()` with the option `parser` or `filepath`. ([#620](https://github.com/diffplug/spotless/pull/620)) +### Fixed +* LineEndings.GIT_ATTRIBUTES is now a bit more efficient, and paves the way for remote build cache support in Gradle. ([#621](https://github.com/diffplug/spotless/pull/621)) ## [4.4.0] - 2020-06-19 ### Added From d3d17c04cf980cacf66b011d50650f611818cdb9 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 27 Jun 2020 16:57:01 -0700 Subject: [PATCH 12/13] Fix FormatTaskTest. --- .../test/java/com/diffplug/gradle/spotless/FormatTaskTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/FormatTaskTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/FormatTaskTest.java index 20eb0ab024..9cc838296d 100644 --- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/FormatTaskTest.java +++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/FormatTaskTest.java @@ -37,6 +37,7 @@ public class FormatTaskTest extends ResourceHarness { public void createTask() throws IOException { Project project = TestProvisioner.gradleProject(rootFolder()); spotlessTask = project.getTasks().create("spotlessTaskUnderTest", SpotlessTask.class); + spotlessTask.setLineEndingsPolicy(LineEnding.UNIX.createPolicy()); } @Test @@ -44,7 +45,6 @@ public void testLineEndings() throws Exception { File testFile = setFile("testFile").toContent("\r\n"); File outputFile = new File(spotlessTask.getOutputDirectory(), "testFile"); - spotlessTask.setLineEndingsPolicy(LineEnding.UNIX.createPolicy()); spotlessTask.setTarget(Collections.singleton(testFile)); execute(spotlessTask); From 59b07c7366f2723beb8d8214d281a788d5374197 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 27 Jun 2020 17:21:55 -0700 Subject: [PATCH 13/13] Fix copyright header. --- .../test/java/com/diffplug/gradle/spotless/FormatTaskTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/FormatTaskTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/FormatTaskTest.java index 9cc838296d..8e7ad6bdeb 100644 --- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/FormatTaskTest.java +++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/FormatTaskTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 DiffPlug + * Copyright 2016-2020 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.