Search in sources :

Example 1 with ClassAnalysis

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

the class ClassFilesAnalyzer method visitFile.

@Override
public void visitFile(FileVisitDetails fileDetails) {
    if (!fileDetails.getName().endsWith(".class")) {
        return;
    }
    HashCode hash = hasher.hash(fileDetails);
    ClassAnalysis analysis = analyzer.getClassAnalysis(hash, fileDetails);
    accumulator.addClass(fileDetails.getFile(), analysis);
}
Also used : HashCode(com.google.common.hash.HashCode) ClassAnalysis(org.gradle.api.internal.tasks.compile.incremental.deps.ClassAnalysis)

Example 2 with ClassAnalysis

use of org.gradle.api.internal.tasks.compile.incremental.deps.ClassAnalysis 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(com.google.common.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

HashCode (com.google.common.hash.HashCode)2 ClassAnalysis (org.gradle.api.internal.tasks.compile.incremental.deps.ClassAnalysis)2 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 ClassDependentsAccumulator (org.gradle.api.internal.tasks.compile.incremental.deps.ClassDependentsAccumulator)1