diff --git a/src/it/projects/MJAVADOC-679_encoding/module1/pom.xml b/src/it/projects/MJAVADOC-679_encoding/module1/pom.xml
new file mode 100644
index 000000000..1b6b9fab7
--- /dev/null
+++ b/src/it/projects/MJAVADOC-679_encoding/module1/pom.xml
@@ -0,0 +1,49 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.plugins.javadoc.it
+ mjavadoc679
+ 1.0-SNAPSHOT
+
+ module1
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+
+
+ jar
+
+
+
+
+
+
+
+
diff --git a/src/it/projects/MJAVADOC-679_encoding/module1/src/main/java/com/foo/MyClass.java b/src/it/projects/MJAVADOC-679_encoding/module1/src/main/java/com/foo/MyClass.java
new file mode 100644
index 000000000..385265d97
--- /dev/null
+++ b/src/it/projects/MJAVADOC-679_encoding/module1/src/main/java/com/foo/MyClass.java
@@ -0,0 +1,26 @@
+package com.foo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Arrays;
+
+public class MyClass
+{
+}
diff --git a/src/it/projects/MJAVADOC-679_encoding/pom.xml b/src/it/projects/MJAVADOC-679_encoding/pom.xml
new file mode 100644
index 000000000..d0d3d0e25
--- /dev/null
+++ b/src/it/projects/MJAVADOC-679_encoding/pom.xml
@@ -0,0 +1,59 @@
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.plugins.javadoc.it
+ mjavadoc679
+ 1.0-SNAPSHOT
+ pom
+
+ https://issues.apache.org/jira/browse/MJAVADOC-679
+
+
+ UTF-8
+ @maven.compiler.source@
+ @maven.compiler.target@
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ @project.version@
+
+
+
+
+
+
+ môdülé
+
+
diff --git a/src/it/projects/MJAVADOC-679_encoding/setup.groovy b/src/it/projects/MJAVADOC-679_encoding/setup.groovy
new file mode 100644
index 000000000..e6403b352
--- /dev/null
+++ b/src/it/projects/MJAVADOC-679_encoding/setup.groovy
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+new File(basedir, 'module1').renameTo(new File(basedir, 'môdülé'))
\ No newline at end of file
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
index 05dfe4986..bc81ff6ba 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -114,6 +114,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -4822,15 +4823,18 @@ private void addCommandLineOptions( Commandline cmd, List arguments, Fil
options.append( StringUtils.join( arguments.iterator(),
SystemUtils.LINE_SEPARATOR ) );
- /* default to platform encoding */
- String outputFileEncoding = null;
+ Charset outputFileEncoding;
if ( JAVA_VERSION.isAtLeast( "9" ) && JAVA_VERSION.isBefore( "12" ) )
{
- outputFileEncoding = StandardCharsets.UTF_8.name();
+ outputFileEncoding = StandardCharsets.UTF_8;
+ }
+ else
+ {
+ outputFileEncoding = Charset.defaultCharset();
}
try
{
- FileUtils.fileWrite( optionsFile.getAbsolutePath(), outputFileEncoding, options.toString() );
+ Files.write( optionsFile.toPath(), Collections.singleton( options ), outputFileEncoding );
}
catch ( IOException e )
{
@@ -4880,10 +4884,20 @@ private void addCommandLineArgFile( Commandline cmd, File javadocOutputDirectory
quotedFiles.add( JavadocUtil.quotedPathArgument( file ) );
}
+ Charset cs;
+ if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "9" )
+ && JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore( "12" ) )
+ {
+ cs = StandardCharsets.UTF_8;
+ }
+ else
+ {
+ cs = Charset.defaultCharset();
+ }
+
try
{
- FileUtils.fileWrite( argfileFile.getAbsolutePath(), null /* platform encoding */,
- StringUtils.join( quotedFiles.iterator(), SystemUtils.LINE_SEPARATOR ) );
+ Files.write( argfileFile.toPath(), quotedFiles, cs );
}
catch ( IOException e )
{
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 1e585da1e..a5aa5864c 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java
@@ -21,6 +21,7 @@
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;
@@ -31,7 +32,7 @@
import java.util.List;
import org.apache.maven.reporting.MavenReportException;
-import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.Commandline;
@@ -59,12 +60,24 @@ public static String getStaleData( Commandline cmd )
Path dir = cmd.getWorkingDirectory().toPath().toAbsolutePath().normalize();
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 ), StandardCharsets.UTF_8 ) );
+ options.addAll( Files.readAllLines( dir.resolve( name ), cs ) );
ignored.add( name );
}
}
@@ -130,7 +143,7 @@ public static void writeStaleData( Commandline cmd, Path path )
{
String curdata = getStaleData( cmd );
Files.createDirectories( path.getParent() );
- FileUtils.fileWrite( path.toFile(), null /* platform encoding */, curdata );
+ Files.write( path, Collections.singleton( curdata ), Charset.defaultCharset() );
}
catch ( IOException e )
{