2020
2121import java .io .File ;
2222import java .io .IOException ;
23- import java .nio .charset .Charset ;
2423import java .nio .charset .StandardCharsets ;
2524import java .nio .file .DirectoryStream ;
2625import java .nio .file .Files ;
3130import java .util .List ;
3231
3332import org .apache .maven .reporting .MavenReportException ;
34- import org .codehaus .plexus .languages .java .version .JavaVersion ;
3533import org .codehaus .plexus .util .cli .Commandline ;
3634
3735/**
4139public class StaleHelper {
4240
4341 /**
44- * Compute the encoding of the stale javadoc
45- *
46- * @return the encoding of the stale data
47- */
48- private static Charset getDataCharset () {
49- if (JavaVersion .JAVA_SPECIFICATION_VERSION .isAtLeast ("9" )
50- && JavaVersion .JAVA_SPECIFICATION_VERSION .isBefore ("12" )) {
51- return StandardCharsets .UTF_8 ;
52- } else {
53- return Charset .defaultCharset ();
54- }
55- }
56-
57- /**
58- * Compute the data used to detect a stale javadoc
42+ * Compute the data used to detect a stale javadoc.
5943 *
6044 * @param cmd the command line
6145 * @return the stale data
@@ -72,7 +56,7 @@ public static List<String> getStaleData(Commandline cmd) throws MavenReportExcep
7256 for (String arg : args ) {
7357 if (arg .startsWith ("@" )) {
7458 String name = arg .substring (1 );
75- options .addAll (Files .readAllLines (dir .resolve (name ), getDataCharset () ));
59+ options .addAll (Files .readAllLines (dir .resolve (name ), StandardCharsets . UTF_8 ));
7660 ignored .add (name );
7761 }
7862 }
@@ -113,17 +97,17 @@ public static List<String> getStaleData(Commandline cmd) throws MavenReportExcep
11397 }
11498
11599 /**
116- * Write the data used to detect a stale javadoc
100+ * Write the data used to detect a stale javadoc.
117101 *
118102 * @param cmd the command line
119103 * @param path the stale data path
120104 * @throws MavenReportException if an error occurs
121105 */
122106 public static void writeStaleData (Commandline cmd , Path path ) throws MavenReportException {
123107 try {
124- List <String > curdata = getStaleData (cmd );
108+ List <String > currentData = getStaleData (cmd );
125109 Files .createDirectories (path .getParent ());
126- Files .write (path , curdata , getDataCharset () );
110+ Files .write (path , currentData , StandardCharsets . UTF_8 );
127111 } catch (IOException e ) {
128112 throw new MavenReportException ("Error checking stale data" , e );
129113 }
0 commit comments