Skip to content

Commit

Permalink
Fix hardcoded path exclusions in ResourceParser not working at all on…
Browse files Browse the repository at this point in the history
… Windows, and working too broadly on linux/mac. See openrewrite/rewrite#1293
  • Loading branch information
sambsnyd committed Feb 17, 2022
1 parent 647e9f9 commit b8106e2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/org/openrewrite/maven/ResourceParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ public <S extends SourceFile> List<S> parseSourceFiles(
return false;
}

String pathStr = path.toString();
if (pathStr.contains("/target/") || pathStr.contains("/build/") || pathStr.contains("/out/") ||
pathStr.contains("/.gradle/") || pathStr.contains("/node_modules/") || pathStr.contains("/.metadata/")) {
return false;
for(Path pathSegment : searchDir.relativize(path)) {
String pathStr = pathSegment.toString();
if("target".equals(pathStr) || "build".equals(pathStr) || "out".equals(pathStr) ||
".gradle".equals(pathStr) || "node_modules".equals(pathStr) || ".metadata".equals(pathStr)) {
return false;
}
}

if (attrs.isDirectory() || attrs.size() == 0) {
Expand Down

0 comments on commit b8106e2

Please sign in to comment.