Search in sources :

Example 1 with FileType

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));
}
Also used : List(java.util.List) Iterator(java.util.Iterator) ListMultimap(com.google.common.collect.ListMultimap) MultimapBuilder(com.google.common.collect.MultimapBuilder) Entry.comparingByKey(java.util.Map.Entry.comparingByKey) Map(java.util.Map) Entry(java.util.Map.Entry) Optional(java.util.Optional) Set(java.util.Set) FileType(org.gradle.internal.file.FileType) FileSystemLocationFingerprint(org.gradle.internal.fingerprint.FileSystemLocationFingerprint) FileType(org.gradle.internal.file.FileType)

Example 2 with FileType

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;
}
Also used : FileSystemLocationFingerprint(org.gradle.internal.fingerprint.FileSystemLocationFingerprint) FileType(org.gradle.internal.file.FileType)

Example 3 with FileType

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;
}
Also used : FileSystemLocationFingerprint(org.gradle.internal.fingerprint.FileSystemLocationFingerprint) FileType(org.gradle.internal.file.FileType)

Example 4 with FileType

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);
}
Also used : FileType(org.gradle.internal.file.FileType)

Example 5 with FileType

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);
}
Also used : FileType(org.gradle.internal.file.FileType)

Aggregations

FileType (org.gradle.internal.file.FileType)7 FileSystemLocationFingerprint (org.gradle.internal.fingerprint.FileSystemLocationFingerprint)3 ListMultimap (com.google.common.collect.ListMultimap)1 MultimapBuilder (com.google.common.collect.MultimapBuilder)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Entry.comparingByKey (java.util.Map.Entry.comparingByKey)1 Optional (java.util.Optional)1 Set (java.util.Set)1 DefaultFileSystemLocationFingerprint (org.gradle.internal.fingerprint.impl.DefaultFileSystemLocationFingerprint)1 HashCode (org.gradle.internal.hash.HashCode)1