Search in sources :

Example 11 with FileVisitDetails

use of org.gradle.api.file.FileVisitDetails in project gradle by gradle.

the class PathKeyFileStore method search.

public Set<? extends LocallyAvailableResource> search(String pattern) {
    if (!getBaseDir().exists()) {
        return Collections.emptySet();
    }
    final Set<LocallyAvailableResource> entries = new HashSet<LocallyAvailableResource>();
    findFiles(pattern).visit(new EmptyFileVisitor() {

        public void visitFile(FileVisitDetails fileDetails) {
            final File file = fileDetails.getFile();
            // the file system visitor stuff can't handle the file system mutating while visiting
            if (!isInProgressMarkerFile(file) && !isInProgressFile(file)) {
                entries.add(entryAt(file));
            }
        }
    });
    return entries;
}
Also used : FileVisitDetails(org.gradle.api.file.FileVisitDetails) EmptyFileVisitor(org.gradle.api.file.EmptyFileVisitor) File(java.io.File) HashSet(java.util.HashSet)

Example 12 with FileVisitDetails

use of org.gradle.api.file.FileVisitDetails in project gradle by gradle.

the class IncrementalNativeCompiler method handleDiscoveredInputs.

protected void handleDiscoveredInputs(T spec, IncrementalCompilation compilation, final DiscoveredInputRecorder discoveredInputRecorder) {
    for (File includeFile : compilation.getDiscoveredInputs()) {
        discoveredInputRecorder.newInput(includeFile);
    }
    if (sourceFilesUseMacroIncludes(spec.getSourceFiles(), compilation.getFinalState())) {
        LOGGER.info("After parsing the source files, Gradle cannot calculate the exact set of include files for {}. Every file in the include search path will be considered an input.", task.getName());
        for (final File includeRoot : spec.getIncludeRoots()) {
            LOGGER.info("adding files in {} to discovered inputs for {}", includeRoot, task.getName());
            directoryFileTreeFactory.create(includeRoot).visit(new EmptyFileVisitor() {

                @Override
                public void visitFile(FileVisitDetails fileDetails) {
                    discoveredInputRecorder.newInput(fileDetails.getFile());
                }
            });
        }
    }
}
Also used : FileVisitDetails(org.gradle.api.file.FileVisitDetails) EmptyFileVisitor(org.gradle.api.file.EmptyFileVisitor) File(java.io.File)

Aggregations

FileVisitDetails (org.gradle.api.file.FileVisitDetails)12 FileVisitor (org.gradle.api.file.FileVisitor)6 IOException (java.io.IOException)4 UncheckedIOException (org.gradle.api.UncheckedIOException)4 File (java.io.File)3 RelativePath (org.gradle.api.file.RelativePath)3 DefaultFileVisitDetails (org.gradle.api.internal.file.DefaultFileVisitDetails)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 GradleException (org.gradle.api.GradleException)2 EmptyFileVisitor (org.gradle.api.file.EmptyFileVisitor)2 ClassReader (org.objectweb.asm.ClassReader)2 ImmutableList (com.google.common.collect.ImmutableList)1 HashCode (com.google.common.hash.HashCode)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 HashSet (java.util.HashSet)1 List (java.util.List)1