Search in sources :

Example 6 with FileSystemLocationSnapshot

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

the class OutputFileChanges method index.

private static Map<String, FileSystemLocationSnapshot> index(FileSystemSnapshot snapshot) {
    Map<String, FileSystemLocationSnapshot> index = new LinkedHashMap<>();
    snapshot.accept(new RootTrackingFileSystemSnapshotHierarchyVisitor() {

        @Override
        public SnapshotVisitResult visitEntry(FileSystemLocationSnapshot snapshot, boolean isRoot) {
            // Remove missing roots so they show up as added/removed instead of changed
            if (!(isRoot && snapshot instanceof MissingFileSnapshot)) {
                index.put(snapshot.getAbsolutePath(), snapshot);
            }
            return SnapshotVisitResult.CONTINUE;
        }
    });
    return index;
}
Also used : RootTrackingFileSystemSnapshotHierarchyVisitor(org.gradle.internal.snapshot.RootTrackingFileSystemSnapshotHierarchyVisitor) SnapshotVisitResult(org.gradle.internal.snapshot.SnapshotVisitResult) FileSystemLocationSnapshot(org.gradle.internal.snapshot.FileSystemLocationSnapshot) MissingFileSnapshot(org.gradle.internal.snapshot.MissingFileSnapshot) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with FileSystemLocationSnapshot

use of org.gradle.internal.snapshot.FileSystemLocationSnapshot 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 8 with FileSystemLocationSnapshot

use of org.gradle.internal.snapshot.FileSystemLocationSnapshot 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 9 with FileSystemLocationSnapshot

use of org.gradle.internal.snapshot.FileSystemLocationSnapshot 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)

Example 10 with FileSystemLocationSnapshot

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

the class DefaultSnapshottingService method snapshotFor.

@Override
public Snapshot snapshotFor(Path filePath) {
    String absolutePath = filePath.toAbsolutePath().toString();
    HashCode hash = fileSystemAccess.read(absolutePath, FileSystemLocationSnapshot::getHash);
    return new DefaultSnapshot(hash);
}
Also used : HashCode(org.gradle.internal.hash.HashCode) FileSystemLocationSnapshot(org.gradle.internal.snapshot.FileSystemLocationSnapshot)

Aggregations

FileSystemLocationSnapshot (org.gradle.internal.snapshot.FileSystemLocationSnapshot)12 HashCode (org.gradle.internal.hash.HashCode)6 MissingFileSnapshot (org.gradle.internal.snapshot.MissingFileSnapshot)6 RootTrackingFileSystemSnapshotHierarchyVisitor (org.gradle.internal.snapshot.RootTrackingFileSystemSnapshotHierarchyVisitor)6 SnapshotVisitResult (org.gradle.internal.snapshot.SnapshotVisitResult)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 RegularFileSnapshot (org.gradle.internal.snapshot.RegularFileSnapshot)5 HashSet (java.util.HashSet)4 FileMetadata (org.gradle.internal.file.FileMetadata)3 FileSystemLocationFingerprint (org.gradle.internal.fingerprint.FileSystemLocationFingerprint)3 DirectorySnapshot (org.gradle.internal.snapshot.DirectorySnapshot)3 File (java.io.File)2 HashMap (java.util.HashMap)2 Nullable (javax.annotation.Nullable)2 DefaultFileMetadata (org.gradle.internal.file.impl.DefaultFileMetadata)2 HashMultiset (com.google.common.collect.HashMultiset)1 Multiset (com.google.common.collect.Multiset)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 ArrayDeque (java.util.ArrayDeque)1