Search in sources :

Example 1 with EmptyFileVisitor

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

the class DefaultPathKeyFileStore method search.

@Override
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 2 with EmptyFileVisitor

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

the class AbstractFileTree method getFiles.

public Set<File> getFiles() {
    final Set<File> files = new LinkedHashSet<File>();
    visit(new EmptyFileVisitor() {

        public void visitFile(FileVisitDetails fileDetails) {
            files.add(fileDetails.getFile());
        }
    });
    return files;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) FileVisitDetails(org.gradle.api.file.FileVisitDetails) EmptyFileVisitor(org.gradle.api.file.EmptyFileVisitor) File(java.io.File)

Example 3 with EmptyFileVisitor

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

the class AbstractFileTree method getAsMap.

public Map<String, File> getAsMap() {
    final Map<String, File> map = new LinkedHashMap<String, File>();
    visit(new EmptyFileVisitor() {

        public void visitFile(FileVisitDetails fileDetails) {
            map.put(fileDetails.getRelativePath().getPathString(), fileDetails.getFile());
        }
    });
    return map;
}
Also used : FileVisitDetails(org.gradle.api.file.FileVisitDetails) EmptyFileVisitor(org.gradle.api.file.EmptyFileVisitor) File(java.io.File) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with EmptyFileVisitor

use of org.gradle.api.file.EmptyFileVisitor 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 5 with EmptyFileVisitor

use of org.gradle.api.file.EmptyFileVisitor 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

EmptyFileVisitor (org.gradle.api.file.EmptyFileVisitor)8 FileVisitDetails (org.gradle.api.file.FileVisitDetails)8 File (java.io.File)6 HashSet (java.util.HashSet)2 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 GradleException (org.gradle.api.GradleException)1 Task (org.gradle.api.Task)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 ConventionTask (org.gradle.api.internal.ConventionTask)1 CacheableTask (org.gradle.api.tasks.CacheableTask)1 VerificationTask (org.gradle.api.tasks.VerificationTask)1 PatchedClassReader (org.gradle.util.internal.PatchedClassReader)1