use of org.gradle.internal.file.FileType in project gradle by gradle.
the class NormalizedPathFingerprintCompareStrategy method getChange.
private static Change getChange(String propertyTitle, ListMultimap<String, FilePathWithType> addedFilesByNormalizedPath, FileSystemLocationFingerprint previousFingerprint, FilePathWithType pathWithType) {
String normalizedPath = previousFingerprint.getNormalizedPath();
FileType previousFingerprintType = previousFingerprint.getType();
String absolutePath = pathWithType.getAbsolutePath();
List<FilePathWithType> filePathWithTypes = addedFilesByNormalizedPath.get(normalizedPath);
Optional<FilePathWithType> match = filePathWithTypes.stream().filter(file -> absolutePath.equals(file.getAbsolutePath())).findFirst();
return match.map(filePathWithType -> {
filePathWithTypes.remove(filePathWithType);
return modified(propertyTitle, previousFingerprintType, normalizedPath, filePathWithType);
}).orElseGet(() -> removed(propertyTitle, normalizedPath, pathWithType));
}
use of org.gradle.internal.file.FileType in project gradle by gradle.
the class NormalizedPathFingerprintCompareStrategy method getAddedFilesByNormalizedPath.
private static ListMultimap<String, FilePathWithType> getAddedFilesByNormalizedPath(Map<String, FileSystemLocationFingerprint> currentFingerprints, ListMultimap<FileSystemLocationFingerprint, FilePathWithType> unaccountedForPreviousFiles, Set<Entry<String, FileSystemLocationFingerprint>> previousEntries) {
ListMultimap<String, FilePathWithType> results = MultimapBuilder.linkedHashKeys().arrayListValues(1).build();
for (Entry<String, FileSystemLocationFingerprint> currentEntry : currentFingerprints.entrySet()) {
// skip exact matches
if (previousEntries.contains(currentEntry)) {
continue;
}
String absolutePath = currentEntry.getKey();
FileSystemLocationFingerprint currentFingerprint = currentEntry.getValue();
List<FilePathWithType> previousFilesForFingerprint = unaccountedForPreviousFiles.get(currentFingerprint);
FileType fingerprintType = currentFingerprint.getType();
if (previousFilesForFingerprint.isEmpty()) {
results.put(currentFingerprint.getNormalizedPath(), new FilePathWithType(absolutePath, fingerprintType));
} else {
previousFilesForFingerprint.remove(0);
}
}
return results;
}
use of org.gradle.internal.file.FileType in project gradle by gradle.
the class NormalizedPathFingerprintCompareStrategy method getUnaccountedForPreviousFingerprints.
private static ListMultimap<FileSystemLocationFingerprint, FilePathWithType> getUnaccountedForPreviousFingerprints(Map<String, FileSystemLocationFingerprint> previousFingerprints, Set<Entry<String, FileSystemLocationFingerprint>> currentEntries) {
ListMultimap<FileSystemLocationFingerprint, FilePathWithType> results = MultimapBuilder.hashKeys(previousFingerprints.size()).linkedListValues().build();
for (Entry<String, FileSystemLocationFingerprint> previousEntry : previousFingerprints.entrySet()) {
// skip exact matches
if (currentEntries.contains(previousEntry)) {
continue;
}
String absolutePath = previousEntry.getKey();
FileSystemLocationFingerprint previousFingerprint = previousEntry.getValue();
FileType previousFingerprintType = previousFingerprint.getType();
results.put(previousFingerprint, new FilePathWithType(absolutePath, previousFingerprintType));
}
return results;
}
use of org.gradle.internal.file.FileType in project gradle by gradle.
the class NormalizedPathFingerprintCompareStrategy method removed.
private static Change removed(String propertyTitle, String normalizedPath, FilePathWithType removedFile) {
String absolutePath = removedFile.getAbsolutePath();
FileType fileType = removedFile.getFileType();
return DefaultFileChange.removed(absolutePath, propertyTitle, fileType, normalizedPath);
}
use of org.gradle.internal.file.FileType in project gradle by gradle.
the class NormalizedPathFingerprintCompareStrategy method added.
private static Change added(String propertyTitle, Entry<String, FilePathWithType> addedFilesByNormalizedPathEntries) {
FilePathWithType addedFile = addedFilesByNormalizedPathEntries.getValue();
String absolutePath = addedFile.getAbsolutePath();
FileType fileType = addedFile.getFileType();
String normalizedPath = addedFilesByNormalizedPathEntries.getKey();
return DefaultFileChange.added(absolutePath, propertyTitle, fileType, normalizedPath);
}
Aggregations