Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/it/projects/MJAVADOC-679_encoding/setup.groovy

This file was deleted.

26 changes: 5 additions & 21 deletions src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
Expand All @@ -31,7 +30,6 @@
import java.util.List;

import org.apache.maven.reporting.MavenReportException;
import org.codehaus.plexus.languages.java.version.JavaVersion;
import org.codehaus.plexus.util.cli.Commandline;

/**
Expand All @@ -41,21 +39,7 @@
public class StaleHelper {

/**
* Compute the encoding of the stale javadoc
*
* @return 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
* Compute the data used to detect a stale javadoc.
*
* @param cmd the command line
* @return the stale data
Expand All @@ -72,7 +56,7 @@ public static List<String> getStaleData(Commandline cmd) throws MavenReportExcep
for (String arg : args) {
if (arg.startsWith("@")) {
String name = arg.substring(1);
options.addAll(Files.readAllLines(dir.resolve(name), getDataCharset()));
options.addAll(Files.readAllLines(dir.resolve(name), StandardCharsets.UTF_8));
ignored.add(name);
}
}
Expand Down Expand Up @@ -113,17 +97,17 @@ public static List<String> getStaleData(Commandline cmd) throws MavenReportExcep
}

/**
* Write the data used to detect a stale javadoc
* Write the data used to detect a stale javadoc.
*
* @param cmd the command line
* @param path the stale data path
* @throws MavenReportException if an error occurs
*/
public static void writeStaleData(Commandline cmd, Path path) throws MavenReportException {
try {
List<String> curdata = getStaleData(cmd);
List<String> currentData = getStaleData(cmd);
Files.createDirectories(path.getParent());
Files.write(path, curdata, getDataCharset());
Files.write(path, currentData, StandardCharsets.UTF_8);
} catch (IOException e) {
throw new MavenReportException("Error checking stale data", e);
}
Expand Down
Loading