private void createPropertiesFile()

in src/main/java/org/apache/maven/shared/archiver/PomPropertiesUtil.java [51:71]


    private void createPropertiesFile(Properties properties, Path outputFile) throws IOException {
        Path outputDir = outputFile.getParent();
        if (outputDir != null) {
            Files.createDirectories(outputDir);
        }
        // For reproducible builds, sort the properties and drop comments.
        // The java.util.Properties class doesn't guarantee order so we have
        // to write the file using a Writer.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        properties.store(baos, null);
        // The encoding can be either UTF-8 or ISO-8859-1, as any non ascii character
        // is transformed into a \\uxxxx sequence anyway
        String output = baos.toString(StandardCharsets.ISO_8859_1)
                .lines()
                .filter(line -> !line.startsWith("#"))
                .sorted()
                .collect(Collectors.joining("\n", "", "\n")); // system independent new line
        try (Writer writer = new CachingWriter(outputFile, StandardCharsets.ISO_8859_1)) {
            writer.write(output);
        }
    }