use of com.facebook.buck.io.PathOrGlobMatcher in project buck by facebook.
the class FilesystemBackedBuildFileTree method getChildPaths.
/**
* @return paths relative to BuildTarget that contain their own build files.
*/
@Override
public Collection<Path> getChildPaths(BuildTarget target) {
// Crawl the subdirectories of target's base path, looking for build files.
// When we find one, we can stop crawling anything under the directory it's in.
final ImmutableSet.Builder<Path> childPaths = ImmutableSet.builder();
final Path basePath = target.getBasePath();
final ImmutableSet<PathOrGlobMatcher> ignoredPaths = projectFilesystem.getIgnorePaths();
try {
projectFilesystem.walkRelativeFileTree(basePath, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
for (PathOrGlobMatcher ignoredPath : ignoredPaths) {
if (ignoredPath.matches(dir)) {
return FileVisitResult.SKIP_SUBTREE;
}
}
if (dir.equals(basePath)) {
return FileVisitResult.CONTINUE;
}
Path buildFile = dir.resolve(buildFileName);
if (pathExistenceCache.getUnchecked(buildFile)) {
childPaths.add(basePath.relativize(dir));
return FileVisitResult.SKIP_SUBTREE;
}
return FileVisitResult.CONTINUE;
}
});
} catch (IOException e) {
throw new RuntimeException(e);
}
return childPaths.build();
}
Aggregations