public void action()

in build-tools/src/main/java/co/elastic/otel/android/compilation/tools/tasks/CreateDependenciesListTask.java [43:78]


    public void action() {
        Map<License, List<ArtifactIdentification>> licensedArtifacts = getLicensedArtifacts();
        List<License> sortedLicenses = new ArrayList<>(licensedArtifacts.keySet());
        sortedLicenses.sort(Comparator.comparing(it -> it.name.toLowerCase(Locale.US)));

        try {
            OutputStream stream = new FileOutputStream(getOutputFile().get().getAsFile());
            boolean firstIteration = true;
            for (License license : sortedLicenses) {
                if (!firstIteration) {
                    TextUtils.addSeparator(stream, '-');
                } else {
                    firstIteration = false;
                }
                TextUtils.writeText(stream, String.format(LICENSE_TITLE_FORMAT, license.name));
                List<ArtifactIdentification> identifications = licensedArtifacts.get(license);
                identifications.sort(Comparator.comparing(it -> it.getDisplayName().toLowerCase(Locale.US)));
                Map<String, List<ArtifactIdentification>> linesSet = new HashMap<>();
                for (ArtifactIdentification identification : identifications) {
                    String displayName = identification.getDisplayName();
                    if (!linesSet.containsKey(displayName)) {
                        addDependencyLine(stream, displayName);
                        List<ArtifactIdentification> artifacts = new ArrayList<>();
                        artifacts.add(identification);
                        linesSet.put(displayName, artifacts);
                    } else {
                        linesSet.get(displayName).add(identification);
                    }
                }
                verifyDuplicatedLines(linesSet);
            }
            stream.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }