|
80 | 80 | import java.nio.file.Files;
|
81 | 81 | import java.nio.file.Path;
|
82 | 82 | import java.nio.file.PathMatcher;
|
| 83 | +import java.nio.file.Paths; |
83 | 84 | import java.util.*;
|
84 | 85 | import java.util.concurrent.atomic.AtomicBoolean;
|
85 | 86 | import java.util.function.Consumer;
|
@@ -614,7 +615,7 @@ public Stream<SourceFile> parse(Project subproject, Set<Path> alreadyParsed, Exe
|
614 | 615 | Collection<PathMatcher> exclusions = extension.getExclusions().stream()
|
615 | 616 | .map(pattern -> subproject.getProjectDir().toPath().getFileSystem().getPathMatcher("glob:" + pattern))
|
616 | 617 | .collect(toList());
|
617 |
| - if (isExcluded(exclusions, subproject.getProjectDir().toPath())) { |
| 618 | + if (isExcluded(exclusions, baseDir.relativize(subproject.getProjectDir().toPath()))) { |
618 | 619 | logger.lifecycle("Skipping project {} because it is excluded", subproject.getPath());
|
619 | 620 | return Stream.empty();
|
620 | 621 | }
|
@@ -909,31 +910,35 @@ private SourceFileStream parseGradleFiles(
|
909 | 910 | if (gradleParser == null) {
|
910 | 911 | gradleParser = gradleParser();
|
911 | 912 | }
|
912 |
| - sourceFiles = Stream.concat( |
913 |
| - sourceFiles, |
914 |
| - gradleParser |
915 |
| - .parse(singleton(settingsGradleFile.toPath()), baseDir, ctx) |
916 |
| - .map(sourceFile -> { |
917 |
| - if (finalGs == null) { |
918 |
| - return sourceFile; |
919 |
| - } |
920 |
| - return sourceFile.withMarkers(sourceFile.getMarkers().add(finalGs)); |
921 |
| - })); |
922 |
| - gradleFileCount++; |
| 913 | + if(!isExcluded(exclusions, settingsPath)) { |
| 914 | + sourceFiles = Stream.concat( |
| 915 | + sourceFiles, |
| 916 | + gradleParser |
| 917 | + .parse(singleton(settingsGradleFile.toPath()), baseDir, ctx) |
| 918 | + .map(sourceFile -> { |
| 919 | + if (finalGs == null) { |
| 920 | + return sourceFile; |
| 921 | + } |
| 922 | + return sourceFile.withMarkers(sourceFile.getMarkers().add(finalGs)); |
| 923 | + })); |
| 924 | + gradleFileCount++; |
| 925 | + } |
923 | 926 | alreadyParsed.add(settingsGradleFile.toPath());
|
924 | 927 | } else if (settingsGradleKtsFile.exists()) {
|
925 | 928 | Path settingsPath = baseDir.relativize(settingsGradleKtsFile.toPath());
|
926 |
| - sourceFiles = Stream.concat( |
927 |
| - sourceFiles, |
928 |
| - PlainTextParser.builder().build() |
929 |
| - .parse(singleton(settingsGradleKtsFile.toPath()), baseDir, ctx) |
930 |
| - .map(sourceFile -> { |
931 |
| - if (finalGs == null) { |
932 |
| - return sourceFile; |
933 |
| - } |
934 |
| - return sourceFile.withMarkers(sourceFile.getMarkers().add(finalGs)); |
935 |
| - })); |
936 |
| - gradleFileCount++; |
| 929 | + if(!isExcluded(exclusions, settingsPath)) { |
| 930 | + sourceFiles = Stream.concat( |
| 931 | + sourceFiles, |
| 932 | + PlainTextParser.builder().build() |
| 933 | + .parse(singleton(settingsGradleKtsFile.toPath()), baseDir, ctx) |
| 934 | + .map(sourceFile -> { |
| 935 | + if (finalGs == null) { |
| 936 | + return sourceFile; |
| 937 | + } |
| 938 | + return sourceFile.withMarkers(sourceFile.getMarkers().add(finalGs)); |
| 939 | + })); |
| 940 | + gradleFileCount++; |
| 941 | + } |
937 | 942 | alreadyParsed.add(settingsGradleKtsFile.toPath());
|
938 | 943 | }
|
939 | 944 | }
|
@@ -1099,6 +1104,11 @@ private boolean isExcluded(Collection<PathMatcher> exclusions, Path path) {
|
1099 | 1104 | return true;
|
1100 | 1105 | }
|
1101 | 1106 | }
|
| 1107 | + // PathMather will not evaluate the path "build.gradle" to be matched by the pattern "**/build.gradle" |
| 1108 | + // This is counter-intuitive for most users and would otherwise require separate exclusions for files at the root and files in subdirectories |
| 1109 | + if(!path.isAbsolute() && !path.startsWith(File.separator)) { |
| 1110 | + return isExcluded(exclusions, Paths.get("/" + path)); |
| 1111 | + } |
1102 | 1112 | return false;
|
1103 | 1113 | }
|
1104 | 1114 |
|
|
0 commit comments