[ 
https://issues.apache.org/jira/browse/MSHARED-1453?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17901329#comment-17901329
 ] 

ASF GitHub Bot commented on MSHARED-1453:
-----------------------------------------

gnodet commented on PR #77:
URL: https://github.com/apache/maven-archiver/pull/77#issuecomment-2502177476

   I'd go for something like:
   ```
       private void createPropertiesFile(Properties properties, Path outputFile)
               throws IOException {
           Path outputDir = outputFile.getParent();
           if (outputDir != null && !Files.isDirectory(outputDir)) {
               Files.createDirectories(outputDir);
           }
           StringWriter sw = new StringWriter();
           properties.store(sw, null);
           String nl = System.lineSeparator();
           String output = Stream.of(sw.toString().split("\\R"))
                   .filter(line -> !line.startsWith("#"))
                   .sorted()
                   .collect(Collectors.joining(nl, "", nl));
           try (Writer pw = new CachingWriter(outputFile, 
StandardCharsets.ISO_8859_1)) {
               pw.write(output);
           }
       }
   ```




> Canonicalize properties files for reproducible builds
> -----------------------------------------------------
>
>                 Key: MSHARED-1453
>                 URL: https://issues.apache.org/jira/browse/MSHARED-1453
>             Project: Maven Shared Components
>          Issue Type: Bug
>          Components: maven-archiver
>            Reporter: Elliotte Rusty Harold
>            Assignee: Elliotte Rusty Harold
>            Priority: Minor
>
> See discussion on https://github.com/apache/maven-archiver/pull/77/files
> Briefly, properties files have non-unique representations and there's no 
> guarantee two JDKs from different companies and Java versions produce the 
> same byte-per-byte serialization. Our current code accounts for property 
> order and comments, but not variations in escaping (hex vs. UTF-8), separator 
> characters, and insignificant whitespace. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to