in log4j-docgen-asciidoctor-extension/src/main/java/org/apache/logging/log4j/docgen/asciidoctor/ApirefMacro.java [205:247]
private Set<PluginSet> loadDescriptors(
final String directory, final String pathPattern, final boolean dotFilesIncluded) {
final Set<PluginSet> pluginSets = new LinkedHashSet<>();
final PluginBundleStaxReader pluginSetReader = new PluginBundleStaxReader();
final PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher(pathPattern);
try (final Stream<Path> paths = Files.walk(Paths.get(directory))) {
paths.forEach(path -> {
// Skip directories
if (Files.isDirectory(path)) {
return;
}
// Skip dot files
final boolean dotFile =
!dotFilesIncluded && path.getFileName().toString().startsWith(".");
if (dotFile) {
return;
}
// Skip mismatching paths
final boolean matched = pathMatcher.matches(path);
if (!matched) {
return;
}
// Read the descriptor
final PluginSet pluginSet;
try {
pluginSet = pluginSetReader.read(path.toString());
} catch (final Exception error) {
final String message = String.format("failed reading descriptor: `%s`", path);
throw new RuntimeException(message, error);
}
pluginSets.add(pluginSet);
LOGGER.log(Level.FINE, "Loaded descriptor at `{}`.", new Object[] {path});
});
} catch (final IOException error) {
final String message = String.format("failed reading descriptors from directory: `%s`", directory);
throw new UncheckedIOException(message, error);
}
return pluginSets;
}