Search in sources :

Example 6 with FileSystemLocationFingerprint

use of org.gradle.internal.fingerprint.FileSystemLocationFingerprint in project gradle by gradle.

the class FileCollectionFingerprintSerializer method read.

@Override
public FileCollectionFingerprint read(Decoder decoder) throws IOException {
    Map<String, FileSystemLocationFingerprint> fingerprints = fingerprintMapSerializer.read(decoder);
    if (fingerprints.isEmpty()) {
        return FileCollectionFingerprint.EMPTY;
    }
    ImmutableMultimap<String, HashCode> rootHashes = readRootHashes(decoder);
    HashCode strategyConfigurationHash = hashCodeSerializer.read(decoder);
    return new SerializableFileCollectionFingerprint(fingerprints, rootHashes, strategyConfigurationHash);
}
Also used : FileSystemLocationFingerprint(org.gradle.internal.fingerprint.FileSystemLocationFingerprint) HashCode(org.gradle.internal.hash.HashCode)

Example 7 with FileSystemLocationFingerprint

use of org.gradle.internal.fingerprint.FileSystemLocationFingerprint in project gradle by gradle.

the class FingerprintMapSerializer method write.

@Override
public void write(Encoder encoder, Map<String, FileSystemLocationFingerprint> value) throws Exception {
    encoder.writeSmallInt(value.size());
    for (String key : value.keySet()) {
        encoder.writeString(key);
        FileSystemLocationFingerprint fingerprint = value.get(key);
        writeFingerprint(encoder, fingerprint);
    }
}
Also used : IgnoredPathFileSystemLocationFingerprint(org.gradle.internal.fingerprint.impl.IgnoredPathFileSystemLocationFingerprint) DefaultFileSystemLocationFingerprint(org.gradle.internal.fingerprint.impl.DefaultFileSystemLocationFingerprint) FileSystemLocationFingerprint(org.gradle.internal.fingerprint.FileSystemLocationFingerprint)

Example 8 with FileSystemLocationFingerprint

use of org.gradle.internal.fingerprint.FileSystemLocationFingerprint 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)

Example 9 with FileSystemLocationFingerprint

use of org.gradle.internal.fingerprint.FileSystemLocationFingerprint in project gradle by gradle.

the class NameOnlyFingerprintingStrategy method collectFingerprints.

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

        @Override
        public SnapshotVisitResult visitEntry(FileSystemLocationSnapshot snapshot, boolean isRoot) {
            String absolutePath = snapshot.getAbsolutePath();
            if (processedEntries.add(absolutePath) && getDirectorySensitivity().shouldFingerprint(snapshot)) {
                if (isRoot && snapshot.getType() == FileType.Directory) {
                    builder.put(absolutePath, IgnoredPathFileSystemLocationFingerprint.DIRECTORY);
                } else {
                    HashCode normalizedContentHash = getNormalizedContentHash(snapshot, normalizedContentHasher);
                    if (normalizedContentHash != null) {
                        builder.put(absolutePath, new DefaultFileSystemLocationFingerprint(snapshot.getName(), snapshot.getType(), normalizedContentHash));
                    }
                }
            }
            return SnapshotVisitResult.CONTINUE;
        }
    });
    return builder.build();
}
Also used : SnapshotVisitResult(org.gradle.internal.snapshot.SnapshotVisitResult) FileSystemLocationFingerprint(org.gradle.internal.fingerprint.FileSystemLocationFingerprint) FileSystemLocationSnapshot(org.gradle.internal.snapshot.FileSystemLocationSnapshot) ImmutableMap(com.google.common.collect.ImmutableMap) RootTrackingFileSystemSnapshotHierarchyVisitor(org.gradle.internal.snapshot.RootTrackingFileSystemSnapshotHierarchyVisitor) HashCode(org.gradle.internal.hash.HashCode) HashSet(java.util.HashSet)

Example 10 with FileSystemLocationFingerprint

use of org.gradle.internal.fingerprint.FileSystemLocationFingerprint in project gradle by gradle.

the class AbsolutePathFingerprintingStrategy method collectFingerprints.

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

        @Override
        public SnapshotVisitResult visitEntry(FileSystemLocationSnapshot snapshot, boolean isRoot) {
            String absolutePath = snapshot.getAbsolutePath();
            if (processedEntries.add(absolutePath) && getDirectorySensitivity().shouldFingerprint(snapshot)) {
                HashCode normalizedContentHash = getNormalizedContentHash(snapshot, normalizedContentHasher);
                if (normalizedContentHash != null) {
                    builder.put(absolutePath, new DefaultFileSystemLocationFingerprint(snapshot.getAbsolutePath(), snapshot.getType(), normalizedContentHash));
                }
            }
            return SnapshotVisitResult.CONTINUE;
        }
    });
    return builder.build();
}
Also used : SnapshotVisitResult(org.gradle.internal.snapshot.SnapshotVisitResult) FileSystemLocationFingerprint(org.gradle.internal.fingerprint.FileSystemLocationFingerprint) FileSystemLocationSnapshot(org.gradle.internal.snapshot.FileSystemLocationSnapshot) ImmutableMap(com.google.common.collect.ImmutableMap) RootTrackingFileSystemSnapshotHierarchyVisitor(org.gradle.internal.snapshot.RootTrackingFileSystemSnapshotHierarchyVisitor) HashCode(org.gradle.internal.hash.HashCode) HashSet(java.util.HashSet)

Aggregations

FileSystemLocationFingerprint (org.gradle.internal.fingerprint.FileSystemLocationFingerprint)16 ImmutableMap (com.google.common.collect.ImmutableMap)6 DefaultFileSystemLocationFingerprint (org.gradle.internal.fingerprint.impl.DefaultFileSystemLocationFingerprint)6 HashCode (org.gradle.internal.hash.HashCode)6 HashSet (java.util.HashSet)5 FileType (org.gradle.internal.file.FileType)4 IgnoredPathFileSystemLocationFingerprint (org.gradle.internal.fingerprint.impl.IgnoredPathFileSystemLocationFingerprint)3 FileSystemLocationSnapshot (org.gradle.internal.snapshot.FileSystemLocationSnapshot)3 File (java.io.File)2 IOException (java.io.IOException)2 List (java.util.List)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 Nullable (javax.annotation.Nullable)2 ZipInput (org.gradle.api.internal.file.archive.ZipInput)2 FileZipInput (org.gradle.api.internal.file.archive.impl.FileZipInput)2 StreamZipInput (org.gradle.api.internal.file.archive.impl.StreamZipInput)2 RegularFileSnapshotContextHasher (org.gradle.internal.fingerprint.hashing.RegularFileSnapshotContextHasher)2 ResourceHasher (org.gradle.internal.fingerprint.hashing.ResourceHasher)2