in log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/PluginSets.java [31:60]
static Set<PluginSet> ofDescriptorFilesAndFileMatchers(
@Nullable final File[] descriptorFiles, @Nullable final PathMatcherMojo[] descriptorFileMatchers) {
// Check arguments
final File[] effectiveDescriptorFiles = descriptorFiles != null ? descriptorFiles : new File[0];
final PathMatcherMojo[] effectiveDescriptorFileMatchers =
descriptorFileMatchers != null ? descriptorFileMatchers : new PathMatcherMojo[0];
if (effectiveDescriptorFiles.length == 0 && effectiveDescriptorFileMatchers.length == 0) {
throw new IllegalArgumentException(
"at least one of the `descriptorFiles` and `descriptorFileMatchers` configurations must be provided");
}
// Collect paths
final Set<Path> foundDescriptorPaths = /* order matters: */ new LinkedHashSet<>();
Arrays.stream(effectiveDescriptorFiles).map(File::toPath).forEach(foundDescriptorPaths::add);
Arrays.stream(effectiveDescriptorFileMatchers).forEach(matcher -> matcher.findPaths(foundDescriptorPaths::add));
// Create plugin sets
final PluginBundleStaxReader reader = new PluginBundleStaxReader();
return foundDescriptorPaths.stream()
.map(descriptorFile -> {
try {
return reader.read(descriptorFile.toString());
} catch (final Exception error) {
final String message = String.format("failed reading descriptor file `%s`", descriptorFile);
throw new RuntimeException(message, error);
}
})
.collect(Collectors.toCollection(/* order matters: */ LinkedHashSet::new));
}