in src/main/java/org/apache/sling/scriptingbundle/plugin/bnd/BundledScriptsScannerPlugin.java [201:219]
private Stream<Path> walkPath(Path path, Set<PathMatcher> includes, Set<PathMatcher> excludes) throws IOException {
return Files.walk(path).filter(file -> {
boolean include = includes.isEmpty();
Optional<PathMatcher> includeOptions = includes.stream().filter(pathMatcher -> pathMatcher.matches(file)).findFirst();
if (includeOptions.isPresent()) {
include = true;
}
Optional<PathMatcher> excludeOptions = excludes.stream().filter(pathMatcher -> pathMatcher.matches(file)).findFirst();
if (excludeOptions.isPresent()) {
include = false;
}
return include;
}).flatMap(file -> {
if (!Files.isDirectory(file)) {
return Stream.of(file, file.getParent());
}
return Stream.of(file);
});
}