Search in sources :

Example 1 with ClassDependentsAccumulator

use of org.gradle.api.internal.tasks.compile.incremental.deps.ClassDependentsAccumulator in project gradle by gradle.

the class DefaultJarSnapshotter method createSnapshot.

public JarSnapshot createSnapshot(HashCode hash, JarArchive jarArchive) {
    final Map<String, HashCode> hashes = Maps.newHashMap();
    final ClassDependentsAccumulator accumulator = new ClassDependentsAccumulator();
    jarArchive.contents.visit(new FileVisitor() {

        public void visitDir(FileVisitDetails dirDetails) {
        }

        public void visitFile(FileVisitDetails fileDetails) {
            if (!fileDetails.getName().endsWith(".class")) {
                return;
            }
            HashCode classFileHash;
            InputStream inputStream = fileDetails.open();
            try {
                classFileHash = hasher.hash(inputStream);
            } finally {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            ClassAnalysis analysis = analyzer.getClassAnalysis(classFileHash, fileDetails);
            accumulator.addClass(analysis);
            hashes.put(analysis.getClassName(), classFileHash);
        }
    });
    return new JarSnapshot(new JarSnapshotData(hash, hashes, accumulator.getAnalysis()));
}
Also used : HashCode(org.gradle.internal.hash.HashCode) FileVisitDetails(org.gradle.api.file.FileVisitDetails) ClassDependentsAccumulator(org.gradle.api.internal.tasks.compile.incremental.deps.ClassDependentsAccumulator) InputStream(java.io.InputStream) FileVisitor(org.gradle.api.file.FileVisitor) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) ClassAnalysis(org.gradle.api.internal.tasks.compile.incremental.deps.ClassAnalysis)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 FileVisitDetails (org.gradle.api.file.FileVisitDetails)1 FileVisitor (org.gradle.api.file.FileVisitor)1 ClassAnalysis (org.gradle.api.internal.tasks.compile.incremental.deps.ClassAnalysis)1 ClassDependentsAccumulator (org.gradle.api.internal.tasks.compile.incremental.deps.ClassDependentsAccumulator)1 HashCode (org.gradle.internal.hash.HashCode)1