Search in sources :

Example 1 with FileSystemLocationSnapshotVisitor

use of org.gradle.internal.snapshot.FileSystemLocationSnapshot.FileSystemLocationSnapshotVisitor in project gradle by gradle.

the class IgnoredPathFingerprintingStrategy method collectFingerprints.

@Override
public Map<String, FileSystemLocationFingerprint> collectFingerprints(FileSystemSnapshot roots) {
    ImmutableMap.Builder<String, FileSystemLocationFingerprint> builder = ImmutableMap.builder();
    HashSet<String> processedEntries = new HashSet<>();
    roots.accept(snapshot -> {
        snapshot.accept(new FileSystemLocationSnapshotVisitor() {

            @Override
            public void visitRegularFile(RegularFileSnapshot fileSnapshot) {
                visitNonDirectoryEntry(snapshot);
            }

            @Override
            public void visitMissing(MissingFileSnapshot missingSnapshot) {
                visitNonDirectoryEntry(snapshot);
            }

            private void visitNonDirectoryEntry(FileSystemLocationSnapshot snapshot) {
                String absolutePath = snapshot.getAbsolutePath();
                if (processedEntries.add(absolutePath)) {
                    HashCode normalizedContentHash = getNormalizedContentHash(snapshot, normalizedContentHasher);
                    if (normalizedContentHash != null) {
                        builder.put(absolutePath, IgnoredPathFileSystemLocationFingerprint.create(snapshot.getType(), normalizedContentHash));
                    }
                }
            }
        });
        return SnapshotVisitResult.CONTINUE;
    });
    return builder.build();
}
Also used : FileSystemLocationSnapshotVisitor(org.gradle.internal.snapshot.FileSystemLocationSnapshot.FileSystemLocationSnapshotVisitor) FileSystemLocationFingerprint(org.gradle.internal.fingerprint.FileSystemLocationFingerprint) HashCode(org.gradle.internal.hash.HashCode) RegularFileSnapshot(org.gradle.internal.snapshot.RegularFileSnapshot) FileSystemLocationSnapshot(org.gradle.internal.snapshot.FileSystemLocationSnapshot) MissingFileSnapshot(org.gradle.internal.snapshot.MissingFileSnapshot) ImmutableMap(com.google.common.collect.ImmutableMap) HashSet(java.util.HashSet)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 HashSet (java.util.HashSet)1 FileSystemLocationFingerprint (org.gradle.internal.fingerprint.FileSystemLocationFingerprint)1 HashCode (org.gradle.internal.hash.HashCode)1 FileSystemLocationSnapshot (org.gradle.internal.snapshot.FileSystemLocationSnapshot)1 FileSystemLocationSnapshotVisitor (org.gradle.internal.snapshot.FileSystemLocationSnapshot.FileSystemLocationSnapshotVisitor)1 MissingFileSnapshot (org.gradle.internal.snapshot.MissingFileSnapshot)1 RegularFileSnapshot (org.gradle.internal.snapshot.RegularFileSnapshot)1