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;
}
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();
}
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();
}
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();
}
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);
}
Aggregations