private void compareFiles()

in src/main/java/org/apache/maven/buildcache/CacheDiff.java [106:158]


    private void compareFiles(ProjectsInputInfo current, ProjectsInputInfo baseline) {
        final Map<String, DigestItem> currentFiles = current.getItems().stream()
                .filter(item -> "file".equals(item.getType()))
                .collect(Collectors.toMap(DigestItem::getValue, item -> item));

        final Map<String, DigestItem> baselineFiles = baseline.getItems().stream()
                .filter(item -> "file".equals(item.getType()))
                .collect(Collectors.toMap(DigestItem::getValue, item -> item));

        if (!Objects.equals(currentFiles.keySet(), baselineFiles.keySet())) {
            Set<String> currentVsBaseline = diff(currentFiles.keySet(), baselineFiles.keySet());
            Set<String> baselineVsCurrent = diff(baselineFiles.keySet(), currentFiles.keySet());

            addNewMismatch(
                    "source files",
                    "Remote and local cache contain different sets of input files. " + "Added files: "
                            + currentVsBaseline + ". Removed files: " + baselineVsCurrent,
                    "To match remote and local caches should have identical file sets."
                            + " Unnecessary and transient files must be filtered out to make file sets match"
                            + " - see configuration guide");
            return;
        }

        for (Map.Entry<String, DigestItem> entry : currentFiles.entrySet()) {
            String filePath = entry.getKey();
            DigestItem currentFile = entry.getValue();
            // should be null safe because sets are compared above for differences
            final DigestItem baselineFile = baselineFiles.get(filePath);
            if (!StringUtils.equals(currentFile.getHash(), baselineFile.getHash())) {
                String reason = "File content is different.";
                if (currentFile.getEol() != null
                        && baselineFile.getEol() != null
                        && !StringUtils.equals(baselineFile.getEol(), currentFile.getEol())) {
                    reason += " Different line endings detected (text files relevant). " + "Remote: "
                            + baselineFile.getEol() + ", local: " + currentFile.getEol() + ".";
                }
                if (currentFile.getCharset() != null
                        && baselineFile.getCharset() != null
                        && !StringUtils.equals(baselineFile.getCharset(), currentFile.getCharset())) {
                    reason += " Different charset detected (text files relevant). " + "Remote: " + baselineFile.getEol()
                            + ", local: " + currentFile.getEol() + ".";
                }

                addNewMismatch(
                        filePath,
                        currentFile.getHash(),
                        baselineFile.getHash(),
                        reason,
                        "Different content manifests different build outcome. "
                                + "Ensure that difference is not caused by environment specifics, like line separators");
            }
        }
    }