Merge branch '3.3.x'

Closes gh-43062
This commit is contained in:
Moritz Halbritter
2024-11-07 15:26:47 +01:00

View File

@@ -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;
@@ -452,7 +454,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) {