Skip to content

Commit

Permalink
Running :spotlessCheck on Spotless no longer causes it to crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbduncan committed Dec 21, 2016
1 parent d12dbb8 commit e3ec14f
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.gradle.api.GradleException;
Expand Down Expand Up @@ -136,9 +138,10 @@ protected FileCollection parseTarget(Object target) {
} else if (target instanceof String ||
(target instanceof List && ((List<?>) target).stream().allMatch(o -> o instanceof String))) {
File dir = getProject().getProjectDir();
Iterable<String> excludes = Arrays.asList(
getProject().getBuildDir().toString() + File.separatorChar + "**",
getProject().getProjectDir().toString() + File.separatorChar + ".gradle" + File.separatorChar + "**");
Set<Project> subprojects = getProject().getSubprojects();
Stream<String> buildDirs = subprojects.stream().map(subproject -> subproject.getBuildDir().toString() + File.separatorChar + "**");
Stream<String> localDotGradleDirs = subprojects.stream().map(subproject -> subproject.getProjectDir().toString() + File.separatorChar + ".gradle" + File.separatorChar + "**");
Iterable<String> excludes = Stream.concat(buildDirs, localDotGradleDirs).collect(Collectors.toList());
if (target instanceof String) {
return (FileCollection) getProject().fileTree(dir).include((String) target).exclude(excludes);
} else {
Expand Down

4 comments on commit e3ec14f

@nedtwigg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, but I don't think gradle is sensitive to \ vs /.

@jbduncan
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, thanks for the tip @nedtwigg. I'll quickly implement a shortened version now then.

Unfortunately, as I just posted in #31 (comment), it seems my "fix" here doesn't actually work! So I'll investigate this some other time, not now as it's bedtime for me. :)

@nedtwigg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I think this change was still a good idea for performance, even if it doesn't fix the problem you were trying to fix.

@jbduncan
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, okay, I see. In that case I'll bring back the relevant parts of this commit then. :)

Please sign in to comment.