Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ protected void visitResource(Path relativePath, byte[] content) throws IOExcepti
}

static void visitFiles(Path inputDir, List<Path> includedFiles, FileVisitor<Path> visitor) throws IOException {
if (includedFiles != null) {
visitor = new FilteringFileVisitor(includedFiles, visitor);
}
visitor = new FilteringFileVisitor(includedFiles, visitor);
Files.walkFileTree(inputDir, visitor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class FilteringFileVisitor implements FileVisitor<Path> {
private final FileVisitor<? super Path> target;

public FilteringFileVisitor(Collection<Path> fileFilter, FileVisitor<Path> target) {
this.fileFilter = new HashSet<>(fileFilter);
this.fileFilter = fileFilter == null ? null : new HashSet<>(fileFilter);
this.target = target;
}

Expand All @@ -26,12 +26,15 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx

@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
if (dir.toString().endsWith("/META-INF/versions")) {
return FileVisitResult.SKIP_SUBTREE;
}
return target.preVisitDirectory(dir, attrs);
}

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (fileFilter.contains(file)) {
if (fileFilter == null || fileFilter.contains(file)) {
return target.visitFile(file, attrs);
} else {
return FileVisitResult.CONTINUE;
Expand Down