use of org.gradle.internal.fingerprint.FileSystemLocationFingerprint 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();
}
use of org.gradle.internal.fingerprint.FileSystemLocationFingerprint 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();
}
use of org.gradle.internal.fingerprint.FileSystemLocationFingerprint in project gradle by gradle.
the class ZipHasher method fingerprintZipEntries.
private void fingerprintZipEntries(String parentName, String rootParentName, List<FileSystemLocationFingerprint> fingerprints, ZipInput input) throws IOException {
fingerprints.add(newZipMarker(parentName));
for (ZipEntry zipEntry : input) {
if (zipEntry.isDirectory()) {
continue;
}
String fullName = parentName.isEmpty() ? zipEntry.getName() : parentName + "/" + zipEntry.getName();
ZipEntryContext zipEntryContext = new DefaultZipEntryContext(zipEntry, fullName, rootParentName);
if (isZipFile(zipEntry.getName())) {
zipEntryContext.getEntry().withInputStream((ZipEntry.InputStreamAction<Void>) inputStream -> {
fingerprintZipEntries(fullName, rootParentName, fingerprints, new StreamZipInput(inputStream));
return null;
});
} else {
fingerprintZipEntry(zipEntryContext, fingerprints);
}
}
}
use of org.gradle.internal.fingerprint.FileSystemLocationFingerprint in project gradle by gradle.
the class ZipHasher method fingerprintZipEntries.
private List<FileSystemLocationFingerprint> fingerprintZipEntries(String zipFile) throws IOException {
try (ZipInput input = FileZipInput.create(new File(zipFile))) {
List<FileSystemLocationFingerprint> fingerprints = Lists.newArrayList();
fingerprintZipEntries("", zipFile, fingerprints, input);
return fingerprints;
}
}
use of org.gradle.internal.fingerprint.FileSystemLocationFingerprint in project gradle by gradle.
the class IgnoredPathCompareStrategy method visitChangesSince.
/**
* Determines changes by:
*
* <ul>
* <li>Determining which content fingerprints are only in the previous or current fingerprint collection.</li>
* <li>Those only in the previous fingerprint collection are reported as removed.</li>
* </ul>
*/
private static boolean visitChangesSince(Map<String, FileSystemLocationFingerprint> previous, Map<String, FileSystemLocationFingerprint> current, String propertyTitle, ChangeVisitor visitor) {
ListMultimap<HashCode, FilePathWithType> unaccountedForPreviousFiles = MultimapBuilder.hashKeys(previous.size()).linkedListValues().build();
for (Map.Entry<String, FileSystemLocationFingerprint> entry : previous.entrySet()) {
String absolutePath = entry.getKey();
FileSystemLocationFingerprint previousFingerprint = entry.getValue();
unaccountedForPreviousFiles.put(previousFingerprint.getNormalizedContentHash(), new FilePathWithType(absolutePath, previousFingerprint.getType()));
}
for (Map.Entry<String, FileSystemLocationFingerprint> entry : current.entrySet()) {
String currentAbsolutePath = entry.getKey();
FileSystemLocationFingerprint currentFingerprint = entry.getValue();
HashCode normalizedContentHash = currentFingerprint.getNormalizedContentHash();
List<FilePathWithType> previousFilesForContent = unaccountedForPreviousFiles.get(normalizedContentHash);
if (previousFilesForContent.isEmpty()) {
DefaultFileChange added = DefaultFileChange.added(currentAbsolutePath, propertyTitle, currentFingerprint.getType(), IgnoredPathFingerprintingStrategy.IGNORED_PATH);
if (!visitor.visitChange(added)) {
return false;
}
} else {
previousFilesForContent.remove(0);
}
}
List<Map.Entry<HashCode, FilePathWithType>> unaccountedForPreviousEntries = ImmutableList.sortedCopyOf(ENTRY_COMPARATOR, unaccountedForPreviousFiles.entries());
for (Map.Entry<HashCode, FilePathWithType> unaccountedForPreviousEntry : unaccountedForPreviousEntries) {
FilePathWithType removedFile = unaccountedForPreviousEntry.getValue();
DefaultFileChange removed = DefaultFileChange.removed(removedFile.getAbsolutePath(), propertyTitle, removedFile.getFileType(), IgnoredPathFingerprintingStrategy.IGNORED_PATH);
if (!visitor.visitChange(removed)) {
return false;
}
}
return true;
}
Aggregations