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