|
34 | 34 | import pl.project13.maven.git.log.MavenLoggerBridge;
|
35 | 35 | import pl.project13.maven.git.util.PropertyManager;
|
36 | 36 |
|
37 |
| -import java.io.File; |
38 |
| -import java.io.FileWriter; |
39 |
| -import java.io.IOException; |
| 37 | +import java.io.*; |
| 38 | +import java.nio.charset.Charset; |
40 | 39 | import java.text.SimpleDateFormat;
|
41 | 40 | import java.util.Collections;
|
42 | 41 | import java.util.Date;
|
@@ -272,7 +271,6 @@ public class GitCommitIdMojo extends AbstractMojo {
|
272 | 271 | @SuppressWarnings("UnusedDeclaration")
|
273 | 272 | private List<String> excludeProperties = Collections.emptyList();
|
274 | 273 |
|
275 |
| - |
276 | 274 | /**
|
277 | 275 | * The properties we store our data in and then expose them
|
278 | 276 | */
|
@@ -487,25 +485,25 @@ void loadGitDataWithJGit(@NotNull Properties properties) throws IOException, Moj
|
487 | 485 | }
|
488 | 486 |
|
489 | 487 | void generatePropertiesFile(@NotNull Properties properties, File base, String propertiesFilename) throws IOException {
|
490 |
| - FileWriter fileWriter = null; |
| 488 | + Writer outputWriter = null; |
491 | 489 | File gitPropsFile = craftPropertiesOutputFile(base, propertiesFilename);
|
492 | 490 | try {
|
493 | 491 | Files.createParentDirs(gitPropsFile);
|
494 | 492 |
|
495 |
| - fileWriter = new FileWriter(gitPropsFile); |
| 493 | + outputWriter = new OutputStreamWriter(new FileOutputStream(gitPropsFile), Charset.forName("UTF-8")); |
496 | 494 | if ("json".equalsIgnoreCase(format)) {
|
497 | 495 | log("Writing json file to [", gitPropsFile.getAbsolutePath(), "] (for module ", project.getName(), ")...");
|
498 | 496 | ObjectMapper mapper = new ObjectMapper();
|
499 |
| - mapper.writeValue(fileWriter, properties); |
| 497 | + mapper.writeValue(outputWriter, properties); |
500 | 498 | } else {
|
501 | 499 | log("Writing properties file to [", gitPropsFile.getAbsolutePath(), "] (for module ", project.getName(), ")...");
|
502 |
| - properties.store(fileWriter, "Generated by Git-Commit-Id-Plugin"); |
| 500 | + properties.store(outputWriter, "Generated by Git-Commit-Id-Plugin"); |
503 | 501 | }
|
504 | 502 |
|
505 | 503 | } catch (IOException ex) {
|
506 | 504 | throw new RuntimeException("Cannot create custom git properties file: " + gitPropsFile, ex);
|
507 | 505 | } finally {
|
508 |
| - Closeables.closeQuietly(fileWriter); |
| 506 | + Closeables.closeQuietly(outputWriter); |
509 | 507 | }
|
510 | 508 | }
|
511 | 509 |
|
|
0 commit comments