Use native encoding when writing the java arguments file
Closes gh-43051
This commit is contained in:
parent
32c61a99e4
commit
317d943083
|
@ -20,6 +20,8 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
|
@ -469,7 +471,20 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
|||
record ArgFile(Path path) {
|
||||
|
||||
private void write(CharSequence content) throws IOException {
|
||||
Files.writeString(this.path, "\"" + escape(content) + "\"");
|
||||
Files.writeString(this.path, "\"" + escape(content) + "\"", getCharset());
|
||||
}
|
||||
|
||||
private Charset getCharset() {
|
||||
String nativeEncoding = System.getProperty("native.encoding");
|
||||
if (nativeEncoding == null) {
|
||||
return Charset.defaultCharset();
|
||||
}
|
||||
try {
|
||||
return Charset.forName(nativeEncoding);
|
||||
}
|
||||
catch (UnsupportedCharsetException ex) {
|
||||
return Charset.defaultCharset();
|
||||
}
|
||||
}
|
||||
|
||||
private String escape(CharSequence content) {
|
||||
|
|
Loading…
Reference in New Issue