You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2021/08/17 19:04:25 UTC

[maven-javadoc-plugin] 01/01: [MJAVADOC-679] "Unable to compute stale date" in a directory with accent characters (charset issue)

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch MJAVADOC-679
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git

commit 7f91cb956c1d5195ed508bbd6281eee5d69953ba
Author: rfscholte <rf...@apache.org>
AuthorDate: Tue Aug 17 21:04:14 2021 +0200

    [MJAVADOC-679] "Unable to compute stale date" in a directory with accent characters (charset issue)
---
 .../projects/MJAVADOC-679_encoding/module1/pom.xml | 49 +++++++++++++++++++
 .../module1/src/main/java/com/foo/MyClass.java     | 26 ++++++++++
 src/it/projects/MJAVADOC-679_encoding/pom.xml      | 57 ++++++++++++++++++++++
 src/it/projects/MJAVADOC-679_encoding/setup.groovy | 20 ++++++++
 .../apache/maven/plugins/javadoc/StaleHelper.java  | 16 +++++-
 5 files changed, 167 insertions(+), 1 deletion(-)

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 0000000..1b6b9fa
--- /dev/null
+++ b/src/it/projects/MJAVADOC-679_encoding/module1/pom.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+    <artifactId>mjavadoc679</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>module1</artifactId>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
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 0000000..385265d
--- /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 0000000..b5d4601
--- /dev/null
+++ b/src/it/projects/MJAVADOC-679_encoding/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+  <artifactId>mjavadoc679</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <url>https://issues.apache.org/jira/browse/MJAVADOC-679</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.8.0</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-javadoc-plugin</artifactId>
+          <version>@project.version@</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+  <modules>
+    <module>môdülé</module>
+  </modules>
+</project>
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 0000000..e6403b3
--- /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/StaleHelper.java b/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java
index 1e585da..cd20abb 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 @@ package org.apache.maven.plugins.javadoc;
 
 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,6 +32,7 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.Commandline;
@@ -59,12 +61,24 @@ public class StaleHelper
             Path dir = cmd.getWorkingDirectory().toPath().toAbsolutePath().normalize();
             String[] args = cmd.getArguments();
             Collections.addAll( options, args );
+            
+            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 );
                 }
             }