use of org.apache.camel.quarkus.core.CamelConfig.ReflectionConfig in project camel-quarkus by apache.
the class CamelNativeImageProcessor method reflection.
@BuildStep
void reflection(CamelConfig config, ApplicationArchivesBuildItem archives, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
final ReflectionConfig reflectionConfig = config.native_.reflection;
if (!reflectionConfig.includePatterns.isPresent()) {
LOGGER.debug("No classes registered for reflection via quarkus.camel.native.reflection.include-patterns");
return;
}
LOGGER.debug("Scanning resources for native inclusion from include-patterns {}", reflectionConfig.includePatterns.get());
final PathFilter.Builder builder = new PathFilter.Builder();
reflectionConfig.includePatterns.map(Collection::stream).orElseGet(Stream::empty).map(className -> className.replace('.', '/')).forEach(builder::include);
reflectionConfig.excludePatterns.map(Collection::stream).orElseGet(Stream::empty).map(className -> className.replace('.', '/')).forEach(builder::exclude);
final PathFilter pathFilter = builder.build();
Stream<Path> archiveRootDirs = archives.getAllApplicationArchives().stream().peek(archive -> LOGGER.debug("Scanning resources for native inclusion from archive at {}", archive.getResolvedPaths())).flatMap(archive -> archive.getRootDirectories().stream());
String[] selectedClassNames = pathFilter.scanClassNames(archiveRootDirs);
if (selectedClassNames.length > 0) {
reflectiveClasses.produce(new ReflectiveClassBuildItem(true, true, selectedClassNames));
}
}
Aggregations