Search in sources :

Example 1 with RelativePathTracker

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

the class TarBuildCacheEntryPacker method packTree.

private long packTree(String name, TreeType type, FileSystemSnapshot snapshots, TarArchiveOutputStream tarOutput) {
    PackingVisitor packingVisitor = new PackingVisitor(tarOutput, name, type, filePermissionAccess);
    snapshots.accept(new RelativePathTracker(), packingVisitor);
    return packingVisitor.getPackedEntryCount();
}
Also used : RelativePathTracker(org.gradle.internal.snapshot.RelativePathTracker)

Example 2 with RelativePathTracker

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

the class RelativePathFingerprintingStrategy 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 RelativePathTracker(), (snapshot, relativePath) -> {
        String absolutePath = snapshot.getAbsolutePath();
        if (processedEntries.add(absolutePath) && getDirectorySensitivity().shouldFingerprint(snapshot)) {
            FileSystemLocationFingerprint fingerprint;
            if (relativePath.isRoot()) {
                if (snapshot.getType() == FileType.Directory) {
                    return SnapshotVisitResult.CONTINUE;
                } else {
                    fingerprint = fingerprint(snapshot.getName(), snapshot.getType(), snapshot);
                }
            } else {
                fingerprint = fingerprint(stringInterner.intern(relativePath.toRelativePath()), snapshot.getType(), snapshot);
            }
            if (fingerprint != null) {
                builder.put(absolutePath, fingerprint);
            }
        }
        return SnapshotVisitResult.CONTINUE;
    });
    return builder.build();
}
Also used : FileSystemLocationFingerprint(org.gradle.internal.fingerprint.FileSystemLocationFingerprint) RelativePathTracker(org.gradle.internal.snapshot.RelativePathTracker) ImmutableMap(com.google.common.collect.ImmutableMap) HashSet(java.util.HashSet)

Example 3 with RelativePathTracker

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

the class FileSystemSnapshotFilter method filterSnapshot.

public static FileSystemSnapshot filterSnapshot(SnapshottingFilter.FileSystemSnapshotPredicate predicate, FileSystemSnapshot unfiltered) {
    DirectorySnapshotBuilder builder = MerkleDirectorySnapshotBuilder.noSortingRequired();
    AtomicBoolean hasBeenFiltered = new AtomicBoolean(false);
    unfiltered.accept(new RelativePathTracker(), new FilteringVisitor(predicate, builder, hasBeenFiltered));
    if (builder.getResult() == null) {
        return FileSystemSnapshot.EMPTY;
    }
    return hasBeenFiltered.get() ? builder.getResult() : unfiltered;
}
Also used : DirectorySnapshotBuilder(org.gradle.internal.snapshot.DirectorySnapshotBuilder) MerkleDirectorySnapshotBuilder(org.gradle.internal.snapshot.MerkleDirectorySnapshotBuilder) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) RelativePathTracker(org.gradle.internal.snapshot.RelativePathTracker)

Example 4 with RelativePathTracker

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

the class ClasspathFingerprintingStrategy 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 RelativePathTracker(), new ClasspathFingerprintingVisitor(processedEntries, builder));
    return builder.build();
}
Also used : IgnoredPathFileSystemLocationFingerprint(org.gradle.internal.fingerprint.impl.IgnoredPathFileSystemLocationFingerprint) FileSystemLocationFingerprint(org.gradle.internal.fingerprint.FileSystemLocationFingerprint) DefaultFileSystemLocationFingerprint(org.gradle.internal.fingerprint.impl.DefaultFileSystemLocationFingerprint) RelativePathTracker(org.gradle.internal.snapshot.RelativePathTracker) ImmutableMap(com.google.common.collect.ImmutableMap) HashSet(java.util.HashSet)

Aggregations

RelativePathTracker (org.gradle.internal.snapshot.RelativePathTracker)4 ImmutableMap (com.google.common.collect.ImmutableMap)2 HashSet (java.util.HashSet)2 FileSystemLocationFingerprint (org.gradle.internal.fingerprint.FileSystemLocationFingerprint)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 DefaultFileSystemLocationFingerprint (org.gradle.internal.fingerprint.impl.DefaultFileSystemLocationFingerprint)1 IgnoredPathFileSystemLocationFingerprint (org.gradle.internal.fingerprint.impl.IgnoredPathFileSystemLocationFingerprint)1 DirectorySnapshotBuilder (org.gradle.internal.snapshot.DirectorySnapshotBuilder)1 MerkleDirectorySnapshotBuilder (org.gradle.internal.snapshot.MerkleDirectorySnapshotBuilder)1