public void visitFolder()

in winegrower-extension/winegrower-build/winegrower-build-common/src/main/java/org/apache/winegrower/extension/build/common/MetadataBuilder.java [92:138]


    public void visitFolder(final String projectArtifactName, final Path root, final FileVisitor<Path> visitor) {
        final Path manifest = root.resolve("META-INF/MANIFEST.MF");
        if (Files.exists(manifest)) {
            try (final InputStream stream = Files.newInputStream(manifest)) {
                onJar(projectArtifactName, new Manifest(stream));
            } catch (final IOException e) {
                throw new IllegalStateException(e);
            }
        } else {
            onJar(projectArtifactName, null);
        }
        try {
            Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
                @Override
                public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
                    if ("META-INF/MANIFEST.MF".equals(root.relativize(file).toString())) {
                        return FileVisitResult.CONTINUE;
                    }
                    onVisit(file);
                    return visitor.visitFile(file, attrs);
                }

                @Override
                public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
                    onVisit(dir);
                    return visitor.postVisitDirectory(dir, exc);
                }

                @Override
                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                    return visitor.preVisitDirectory(dir, attrs);
                }

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

                private void onVisit(final Path path) {
                    onFile(root.relativize(path).toString());
                }
            });
            afterJar();
        } catch (final IOException e) {
            throw new IllegalStateException(e);
        }
    }