Java Code Examples for org.gradle.api.file.FileTree#visit()

The following examples show how to use org.gradle.api.file.FileTree#visit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultJarSnapshotter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
JarSnapshot createSnapshot(byte[] hash, FileTree classes, final ClassFilesAnalyzer analyzer) {
    final Map<String, byte[]> hashes = new HashMap<String, byte[]>();
    classes.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {
        }

        public void visitFile(FileVisitDetails fileDetails) {
            analyzer.visitFile(fileDetails);
            String className = fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", "");
            byte[] classHash = hasher.hash(fileDetails.getFile());
            hashes.put(className, classHash);
        }
    });

    return new JarSnapshot(new JarSnapshotData(hash, hashes, analyzer.getAnalysis()));
}
 
Example 2
Source File: AllFromJarRebuildInfo.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static Set<String> classesInJar(FileTree jarContents) {
    final Set<String> out = new HashSet<String>();
    jarContents.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {}
        public void visitFile(FileVisitDetails fileDetails) {
            out.add(fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", ""));
        }
    });
    return out;
}
 
Example 3
Source File: SerializableCoffeeScriptCompileSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void toRelativeFiles(final FileCollection source, final List<RelativeFile> targets) {
    FileTree fileTree = source.getAsFileTree();

    fileTree.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {}

        public void visitFile(FileVisitDetails fileDetails) {
            targets.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath()));
        }
    });
}
 
Example 4
Source File: ClassSetAnalysisUpdater.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void updateAnalysis(JavaCompileSpec spec) {
    Clock clock = new Clock();
    FileTree tree = fileOperations.fileTree(spec.getDestinationDir());
    ClassFilesAnalyzer analyzer = new ClassFilesAnalyzer(this.analyzer);
    tree.visit(analyzer);
    ClassSetAnalysisData data = analyzer.getAnalysis();
    stash.put(data);
    LOG.info("Class dependency analysis for incremental compilation took {}.", clock.getTime());
}
 
Example 5
Source File: JarSnapshotter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
JarSnapshot createSnapshot(FileTree archivedClasses) {
    final Map<String, byte[]> hashes = new HashMap<String, byte[]>();
    archivedClasses.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {
        }

        public void visitFile(FileVisitDetails fileDetails) {
            hashes.put(fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", ""), hasher.hash(fileDetails.getFile()));
        }
    });
    return new JarSnapshot(hashes);
}
 
Example 6
Source File: SerializableCoffeeScriptCompileSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void toRelativeFiles(final FileCollection source, final List<RelativeFile> targets) {
    FileTree fileTree = source.getAsFileTree();

    fileTree.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {}

        public void visitFile(FileVisitDetails fileDetails) {
            targets.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath()));
        }
    });
}
 
Example 7
Source File: SerializableCoffeeScriptCompileSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void toRelativeFiles(final FileCollection source, final List<RelativeFile> targets) {
    FileTree fileTree = source.getAsFileTree();

    fileTree.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {}

        public void visitFile(FileVisitDetails fileDetails) {
            targets.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath()));
        }
    });
}
 
Example 8
Source File: SerializableCoffeeScriptCompileSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void toRelativeFiles(final FileCollection source, final List<RelativeFile> targets) {
    FileTree fileTree = source.getAsFileTree();

    fileTree.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {}

        public void visitFile(FileVisitDetails fileDetails) {
            targets.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath()));
        }
    });
}
 
Example 9
Source File: ClassSetAnalysisUpdater.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void updateAnalysis(JavaCompileSpec spec) {
    Clock clock = new Clock();
    FileTree tree = fileOperations.fileTree(spec.getDestinationDir());
    ClassFilesAnalyzer analyzer = new ClassFilesAnalyzer(this.analyzer);
    tree.visit(analyzer);
    ClassSetAnalysisData data = analyzer.getAnalysis();
    stash.put(data);
    LOG.info("Class dependency analysis for incremental compilation took {}.", clock.getTime());
}
 
Example 10
Source File: CompositeFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FileTree visit(Closure visitor) {
    for (FileTree tree : getSourceCollections()) {
        tree.visit(visitor);
    }
    return this;
}
 
Example 11
Source File: CompositeFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FileTree visit(FileVisitor visitor) {
    for (FileTree tree : getSourceCollections()) {
        tree.visit(visitor);
    }
    return this;
}
 
Example 12
Source File: CopySpecActionImpl.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(final CopySpecInternal spec) {
    FileTree source = spec.getSource();
    source.visit(new CopyFileVisitorImpl(spec, action, instantiator, fileSystem));
}
 
Example 13
Source File: CompositeFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FileTree visit(FileVisitor visitor) {
    for (FileTree tree : getSourceCollections()) {
        tree.visit(visitor);
    }
    return this;
}
 
Example 14
Source File: CopySpecActionImpl.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(final CopySpecResolver specResolver) {
    FileTree source = specResolver.getSource();
    source.visit(new CopyFileVisitorImpl(specResolver, action, instantiator, fileSystem));
}
 
Example 15
Source File: CompositeFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FileTree visit(FileVisitor visitor) {
    for (FileTree tree : getSourceCollections()) {
        tree.visit(visitor);
    }
    return this;
}
 
Example 16
Source File: CompositeFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FileTree visit(Closure visitor) {
    for (FileTree tree : getSourceCollections()) {
        tree.visit(visitor);
    }
    return this;
}
 
Example 17
Source File: CopySpecActionImpl.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(final CopySpecInternal spec) {
    FileTree source = spec.getSource();
    source.visit(new CopyFileVisitorImpl(spec, action, instantiator, fileSystem));
}
 
Example 18
Source File: CompositeFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FileTree visit(FileVisitor visitor) {
    for (FileTree tree : getSourceCollections()) {
        tree.visit(visitor);
    }
    return this;
}
 
Example 19
Source File: CopySpecActionImpl.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(final CopySpecResolver specResolver) {
    FileTree source = specResolver.getSource();
    source.visit(new CopyFileVisitorImpl(specResolver, action, instantiator, fileSystem));
}
 
Example 20
Source File: CompositeFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FileTree visit(Closure visitor) {
    for (FileTree tree : getSourceCollections()) {
        tree.visit(visitor);
    }
    return this;
}