package io.quarkus.deployment.steps;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;

import org.jboss.jandex.Index;
import org.jboss.jandex.Indexer;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.ApplicationIndexBuildItem;
import io.quarkus.deployment.builditem.ArchiveRootBuildItem;

public class ApplicationIndexBuildStep {

    @BuildStep
    ApplicationIndexBuildItem build(ArchiveRootBuildItem root) throws IOException {

        Indexer indexer = new Indexer();
        Files.walkFileTree(root.getArchiveRoot(), new FileVisitor<Path>() {
            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                if (file.toString().endsWith(".class")) {
                    try (InputStream stream = Files.newInputStream(file)) {
                        indexer.index(stream);
                    }
                }
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                return FileVisitResult.CONTINUE;
            }
        });
        Index appIndex = indexer.complete();
        return new ApplicationIndexBuildItem(appIndex);
    }

}
@@ -330,16 +330,49 @@
 Indexer;
+%0Aimport org.jboss.logging.Logger;
 %0A%0Aimport
@@ -583,24 +583,114 @@
 uildStep %7B%0A%0A
+    private static final Logger log = Logger.getLogger(ApplicationIndexBuildStep.class);%0A%0A
     @BuildSt
@@ -1271,24 +1271,77 @@
 .class%22)) %7B%0A
+                    log.debugf(%22Indexing %25s%22, file);%0A
             
@@ -2048,9 +2048,10 @@
 %0A    %7D%0A%0A
-
 %7D
+%0A

Add debug logging when indexing files