Skip to content

Commit

Permalink
Allow "**/" exclusion patterns to match files in the root project
Browse files Browse the repository at this point in the history
  • Loading branch information
sambsnyd committed Oct 27, 2023
1 parent d75c38a commit 558223d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/org/openrewrite/maven/ResourceParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.openrewrite.xml.XmlParser;
import org.openrewrite.yaml.YamlParser;

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.*;
Expand Down Expand Up @@ -251,13 +252,16 @@ private boolean isOverSizeThreshold(long fileSize) {
}

private boolean isExcluded(Path path) {
if (!exclusions.isEmpty()) {
for (PathMatcher excluded : exclusions) {
if (excluded.matches(baseDir.relativize(path))) {
return true;
}
for (PathMatcher excluded : exclusions) {
if (excluded.matches(path)) {
return true;
}
}
// PathMather will not evaluate the path "pom.xml" to be matched by the pattern "**/pom.xml"
// This is counter-intuitive for most users and would otherwise require separate exclusions for files at the root and files in subdirectories
if(!path.isAbsolute() && !path.startsWith(File.separator)) {
return isExcluded(Paths.get("/" + path));
}
return false;
}

Expand Down

0 comments on commit 558223d

Please sign in to comment.