Search in sources :

Example 11 with FileVisitor

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

the class AbstractFileCollection method visitAll.

/**
 * Visits all the files of the given tree.
 */
protected static boolean visitAll(FileSystemMirroringFileTree tree) {
    final MutableBoolean hasContent = new MutableBoolean();
    tree.visit(new FileVisitor() {

        @Override
        public void visitDir(FileVisitDetails dirDetails) {
            dirDetails.getFile();
            hasContent.set(true);
        }

        @Override
        public void visitFile(FileVisitDetails fileDetails) {
            fileDetails.getFile();
            hasContent.set(true);
        }
    });
    return hasContent.get();
}
Also used : FileVisitDetails(org.gradle.api.file.FileVisitDetails) MutableBoolean(org.gradle.internal.MutableBoolean) FileVisitor(org.gradle.api.file.FileVisitor)

Example 12 with FileVisitor

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

the class FilteredMinimalFileTree method visit.

@Override
public void visit(FileVisitor visitor) {
    Spec<FileTreeElement> spec = patterns.getAsSpec();
    tree.visit(new FileVisitor() {

        @Override
        public void visitDir(FileVisitDetails dirDetails) {
            if (spec.isSatisfiedBy(dirDetails)) {
                visitor.visitDir(dirDetails);
            }
        }

        @Override
        public void visitFile(FileVisitDetails fileDetails) {
            if (spec.isSatisfiedBy(fileDetails)) {
                visitor.visitFile(fileDetails);
            }
        }
    });
}
Also used : FileVisitDetails(org.gradle.api.file.FileVisitDetails) FileTreeElement(org.gradle.api.file.FileTreeElement) FileVisitor(org.gradle.api.file.FileVisitor)

Aggregations

FileVisitor (org.gradle.api.file.FileVisitor)12 FileVisitDetails (org.gradle.api.file.FileVisitDetails)10 IOException (java.io.IOException)4 UncheckedIOException (org.gradle.api.UncheckedIOException)3 InputStream (java.io.InputStream)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 FileTreeElement (org.gradle.api.file.FileTreeElement)2 Expectations (org.jmock.Expectations)2 Test (org.junit.Test)2 Closure (groovy.lang.Closure)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 UncheckedIOException (java.io.UncheckedIOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 JarFile (java.util.jar.JarFile)1 JarOutputStream (java.util.jar.JarOutputStream)1 ZipEntry (java.util.zip.ZipEntry)1