use of io.quarkus.paths.PathVisit in project quarkus by quarkusio.
the class WebJarUtil method copyResources.
private static void copyResources(CurateOutcomeBuildItem curateOutcomeBuildItem, ApplicationConfig config, WebJarBuildItem webJar, ResolvedDependency resourcesArtifact, WebJarResourcesTargetVisitor visitor) {
final ResolvedDependency userApplication = curateOutcomeBuildItem.getApplicationModel().getAppArtifact();
ClassLoader classLoader = WebJarUtil.class.getClassLoader();
resourcesArtifact.getContentTree().accept(webJar.getRoot(), new Consumer<PathVisit>() {
@Override
public void accept(PathVisit pathVisit) {
if (pathVisit == null || !Files.isDirectory(pathVisit.getPath())) {
return;
}
List<WebJarResourcesFilter> filters = new ArrayList<>();
if (webJar.getFilter() != null) {
filters.add(webJar.getFilter());
}
filters.add(new InsertVariablesResourcesFilter(config, userApplication));
try {
Files.walkFileTree(pathVisit.getPath(), new ResourcesFileVisitor(visitor, pathVisit.getPath(), resourcesArtifact, userApplication, new CombinedWebJarResourcesFilter(filters), classLoader, webJar));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
});
}
use of io.quarkus.paths.PathVisit in project quarkus by quarkusio.
the class ApplicationArchiveBuildStep method indexPathTree.
private static Index indexPathTree(PathTree tree, Set<String> removed) throws IOException {
Indexer indexer = new Indexer();
tree.walk(new PathVisitor() {
@Override
public void visitPath(PathVisit visit) {
final Path path = visit.getPath();
final Path fileName = path.getFileName();
if (fileName == null || !fileName.toString().endsWith(".class") || Files.isDirectory(path) || removed != null && removed.contains(visit.getRelativePath("/"))) {
return;
}
try (InputStream in = Files.newInputStream(path)) {
indexer.index(in);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
return indexer.complete();
}
Aggregations