public void action()

in build-tools/src/main/java/co/elastic/otel/android/compilation/tools/tasks/CreateNoticeTask.java [63:96]


    public void action() {
        File licensesFile = getLicensedDependencies().get().getAsFile();
        Set<File> mergedNoticesFile = getMergedNoticeFiles().getFiles();
        List<String> licenseIds = getLicenseIds();
        List<File> filesToMerge = new ArrayList<>();
        if (licensesFile.length() > 0) {
            filesToMerge.add(licensesFile);
        }
        if (!mergedNoticesFile.isEmpty()) {
            File first = mergedNoticesFile.iterator().next();
            if (first != null && first.exists()) {
                filesToMerge.add(first);
            }
        }

        try {
            File metaInfDir = new File(getOutputDir().getAsFile().get(), "META-INF");
            metaInfDir.mkdirs();
            OutputStream outputStream = new FileOutputStream(new File(metaInfDir, "NOTICE"));
            addToOutputStreamAndCloseInput(outputStream, getNoticeHeaderInputStream());
            if (!filesToMerge.isEmpty()) {
                addPanelSeparator(outputStream);
                addFilesContent(outputStream, filesToMerge);
            }
            if (!licenseIds.isEmpty()) {
                addPanelSeparator(outputStream);
                addLicenses(outputStream, licenseIds);
            }
            outputStream.close();
            saveMetadata();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }