From 02555e77f6fc775dd11b599f31341004af5b86aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Thu, 1 Dec 2022 11:18:33 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E4=BF=AE=E5=A4=8D=20`simplify-pom`?= =?UTF-8?q?=20=E5=BD=93=E5=A4=B4=E8=A1=8C=E6=9C=AA=E9=85=8D=E7=BD=AE=20`en?= =?UTF-8?q?coding`=20=E6=97=B6=E6=8A=A5NPE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/mojo/simplify/AbstractSimplifyPomMojo.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/icu/easyj/maven/plugin/mojo/simplify/AbstractSimplifyPomMojo.java b/src/main/java/icu/easyj/maven/plugin/mojo/simplify/AbstractSimplifyPomMojo.java index 787cea1..501ee5f 100644 --- a/src/main/java/icu/easyj/maven/plugin/mojo/simplify/AbstractSimplifyPomMojo.java +++ b/src/main/java/icu/easyj/maven/plugin/mojo/simplify/AbstractSimplifyPomMojo.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Arrays; @@ -67,6 +68,12 @@ public abstract class AbstractSimplifyPomMojo extends AbstractMojo { } } + // Handle encoding + if (model.getModelEncoding() == null) { + getLog().warn("No encoding specified for " + pomFile + ", using " + StandardCharsets.UTF_8); + model.setModelEncoding(StandardCharsets.UTF_8.name()); + } + // Model to String MavenXpp3Writer pomWriter = new MavenXpp3Writer(model, this.fileComment, this.useTabIndent); String pomFileString; -- Gitee