|
19 | 19 |
|
20 | 20 | import nu.studer.java.util.OrderedProperties;
|
21 | 21 | import pl.project13.core.CannotReadFileException;
|
| 22 | +import pl.project13.core.PropertiesFileGenerator; |
22 | 23 |
|
23 | 24 | import javax.annotation.Nonnull;
|
24 | 25 | import javax.annotation.Nullable;
|
25 | 26 | import java.io.*;
|
26 | 27 | import java.nio.charset.Charset;
|
27 | 28 | import java.nio.charset.StandardCharsets;
|
| 29 | +import java.nio.file.Files; |
28 | 30 | import java.util.Map;
|
29 | 31 | import java.util.Properties;
|
30 | 32 |
|
@@ -55,6 +57,16 @@ public static Properties readProperties(@Nonnull File propertiesFile, @Nonnull C
|
55 | 57 | }
|
56 | 58 | }
|
57 | 59 |
|
| 60 | + // For now used by the gradle plugin to expose properties to the project |
| 61 | + public static void dumpProperties(File gitPropsFile, Properties properties, boolean escapeUnicode) throws IOException { |
| 62 | + Files.createDirectories(gitPropsFile.getParentFile().toPath()); |
| 63 | + try (OutputStream outputStream = new FileOutputStream(gitPropsFile)) { |
| 64 | + OrderedProperties sortedLocalProperties = PropertiesFileGenerator.createOrderedProperties(); |
| 65 | + properties.forEach((key, value) -> sortedLocalProperties.setProperty((String) key, (String) value)); |
| 66 | + PropertyManager.dumpProperties(outputStream, sortedLocalProperties, escapeUnicode); |
| 67 | + } |
| 68 | + } |
| 69 | + |
58 | 70 | public static void dumpProperties(OutputStream outputStream, OrderedProperties sortedLocalProperties, boolean escapeUnicode) throws IOException {
|
59 | 71 | try (Writer outputWriter = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)) {
|
60 | 72 | // use the OrderedProperties.store(Writer, ...)-method to avoid illegal reflective access warning
|
|
0 commit comments