All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.kemitix.dependency.digraph.maven.plugin.DefaultSourceFileProvider Maven / Gradle / Ivy

There is a newer version: 0.9.1
Show newest version
package net.kemitix.dependency.digraph.maven.plugin;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

import javax.inject.Inject;

/**
 * Provider walks the directory and builds a list of discovered Java files.
 *
 * @author pcampbell
 */
class DefaultSourceFileProvider implements SourceFileProvider {

    private final SourceFileVisitor fileVisitor;

    private final DigraphMojo mojo;

    @Inject
    DefaultSourceFileProvider(
            final SourceFileVisitor fileVisitor, final DigraphMojo mojo) {
        this.fileVisitor = fileVisitor;
        this.mojo = mojo;
    }

    @Override
    public List process(final List directories) {
        directories.forEach((final String dir) -> {
            try {
                Path start = new File(dir).getAbsoluteFile().toPath();
                Files.walkFileTree(start, fileVisitor);
            } catch (IOException ex) {
                mojo.getLog().error(ex);
            }
        });
        return fileVisitor.getJavaFiles();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy