public void checkDependencies()

in buildSrc/src/main/java/org/elasticsearch/hadoop/gradle/buildtools/DependencyLicensesTask.java [209:258]


    public void checkDependencies() throws IOException, NoSuchAlgorithmException {
        if (dependencies == null) {
            throw new GradleException("No dependencies variable defined.");
        }

        if (dependencies.isEmpty()) {
            if (licensesDir.exists()) {
                throw new GradleException("Licenses dir " + licensesDir + " exists, but there are no dependencies");
            }
            return; // no dependencies to check
        } else if (licensesDir.exists() == false) {
            String deps = "";
            for (File file : dependencies) {
                deps += file.getName() + "\n";
            }
            throw new GradleException("Licences dir " + licensesDir + " does not exist, but there are dependencies: " + deps);
        }

        Map<String, Boolean> licenses = new HashMap<>();
        Map<String, Boolean> notices = new HashMap<>();
        Map<String, Boolean> sources = new HashMap<>();
        Set<File> shaFiles = new HashSet<>();

        for (File file : licensesDir.listFiles()) {
            String name = file.getName();
            if (name.endsWith(SHA_EXTENSION)) {
                shaFiles.add(file);
            } else if (name.endsWith("-LICENSE") || name.endsWith("-LICENSE.txt")) {
                // TODO: why do we support suffix of LICENSE *and* LICENSE.txt??
                licenses.put(name, false);
            } else if (name.contains("-NOTICE") || name.contains("-NOTICE.txt")) {
                notices.put(name, false);
            } else if (name.contains("-SOURCES") || name.contains("-SOURCES.txt")) {
                sources.put(name, false);
            }
        }

        checkDependencies(licenses, notices, sources, shaFiles);

        licenses.forEach((item, exists) -> failIfAnyMissing(item, exists, "license"));

        notices.forEach((item, exists) -> failIfAnyMissing(item, exists, "notice"));

        sources.forEach((item, exists) -> failIfAnyMissing(item, exists, "sources"));

        if (shaFiles.isEmpty() == false) {
            throw new GradleException("Unused sha files found: \n" + joinFilenames(shaFiles));
        }

    }