Search in sources :

Example 1 with PathVisit

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);
            }
        }
    });
}
Also used : ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) PathVisit(io.quarkus.paths.PathVisit) ArrayList(java.util.ArrayList) List(java.util.List) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 2 with PathVisit

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();
}
Also used : Path(java.nio.file.Path) Indexer(org.jboss.jandex.Indexer) InputStream(java.io.InputStream) PathVisitor(io.quarkus.paths.PathVisitor) PathVisit(io.quarkus.paths.PathVisit) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException)

Aggregations

PathVisit (io.quarkus.paths.PathVisit)2 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 ResolvedDependency (io.quarkus.maven.dependency.ResolvedDependency)1 PathVisitor (io.quarkus.paths.PathVisitor)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Indexer (org.jboss.jandex.Indexer)1