68 lines
2.5 KiB
Diff
68 lines
2.5 KiB
Diff
From 33c9f01af9a3d4d28decbabd0bc02c4b3a875c2d Mon Sep 17 00:00:00 2001
|
|
From: Fridrich Strba <fridrich@users.noreply.github.com>
|
|
Date: Tue, 15 Jul 2025 02:23:18 +0200
|
|
Subject: [PATCH 1/3] Be consistent about data encoding when copying files
|
|
(#1215)
|
|
|
|
---
|
|
.../maven/plugins/javadoc/StaleHelper.java | 26 ++++++++++++-------
|
|
1 file changed, 16 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java b/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java
|
|
index aabe9840..7517d0fb 100644
|
|
--- a/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java
|
|
+++ b/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java
|
|
@@ -40,6 +40,20 @@ import org.codehaus.plexus.util.cli.Commandline;
|
|
*/
|
|
public class StaleHelper {
|
|
|
|
+ /**
|
|
+ * Compute the encoding of the stale javadoc
|
|
+ *
|
|
+ * @return the the encoding of the stale data
|
|
+ */
|
|
+ private static Charset getDataCharset() {
|
|
+ if (JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast("9")
|
|
+ && JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore("12")) {
|
|
+ return StandardCharsets.UTF_8;
|
|
+ } else {
|
|
+ return Charset.defaultCharset();
|
|
+ }
|
|
+ }
|
|
+
|
|
/**
|
|
* Compute the data used to detect a stale javadoc
|
|
*
|
|
@@ -55,18 +69,10 @@ public class StaleHelper {
|
|
String[] args = cmd.getArguments();
|
|
Collections.addAll(options, args);
|
|
|
|
- final Charset cs;
|
|
- if (JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast("9")
|
|
- && JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore("12")) {
|
|
- cs = StandardCharsets.UTF_8;
|
|
- } else {
|
|
- cs = Charset.defaultCharset();
|
|
- }
|
|
-
|
|
for (String arg : args) {
|
|
if (arg.startsWith("@")) {
|
|
String name = arg.substring(1);
|
|
- options.addAll(Files.readAllLines(dir.resolve(name), cs));
|
|
+ options.addAll(Files.readAllLines(dir.resolve(name), getDataCharset()));
|
|
ignored.add(name);
|
|
}
|
|
}
|
|
@@ -117,7 +123,7 @@ public class StaleHelper {
|
|
try {
|
|
List<String> curdata = getStaleData(cmd);
|
|
Files.createDirectories(path.getParent());
|
|
- Files.write(path, curdata, StandardCharsets.UTF_8);
|
|
+ Files.write(path, curdata, getDataCharset());
|
|
} catch (IOException e) {
|
|
throw new MavenReportException("Error checking stale data", e);
|
|
}
|
|
--
|
|
2.50.1
|
|
|