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/04/24 11:20:51 UTC

[maven-javadoc-plugin] branch MJAVADOC-662 created (now 52ab114)

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

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


      at 52ab114  add more details to javadocs in test resources.

This branch includes the following new commits:

     new 189fc54  The fix operation wrongly generate illegal javadoc for static final fields.
     new 0f4ba75  change to use StringEscapeUtils in commons-text 1.3 also change the length check to escapedValue instead of raw value.
     new 52ab114  add more details to javadocs in test resources.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[maven-javadoc-plugin] 03/03: add more details to javadocs in test resources.

Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 52ab114d7a937a611b6855671c3b3b9166dcabed
Author: XenoAmess <xe...@gmail.com>
AuthorDate: Wed Dec 16 03:39:34 2020 +0800

    add more details to javadocs in test resources.
---
 .../fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java  | 6 +++---
 .../unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java      | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java b/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java
index 0b5a374..c5a6ba3 100644
--- a/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java
+++ b/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java
@@ -453,17 +453,17 @@ public class ClassWithJavadoc
     }
 
     /**
-     * to test if it will handle static final field correctly.
+     * to test if it will handle static final int field with left shift operators correctly.
      */
     public static final int TEST_STATIC_FINAL_FIELD_0 = 1 << 2;
 
     /**
-     * to test if it will handle static final field correctly.
+     * to test if it will handle static final int field with right shift operators correctly.
      */
     public static final int TEST_STATIC_FINAL_FIELD_1 = 2 >> 1;
 
     /**
-     * to test if it will handle static final field correctly.
+     * to test if it will handle static final String field with left shift operator and right shift operator correctly.
      */
     public static final String TEST_STATIC_FINAL_FIELD_2 = "<>?";
 }
diff --git a/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java b/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java
index ab0d445..e82ecaa 100644
--- a/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java
+++ b/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java
@@ -416,17 +416,17 @@ public class ClassWithJavadoc
     }
 
     /**
-     * to test if it will handle static final field correctly.
+     * to test if it will handle static final int field with left shift operators correctly.
      */
     public static final int TEST_STATIC_FINAL_FIELD_0 = 1 << 2;
 
     /**
-     * to test if it will handle static final field correctly.
+     * to test if it will handle static final int field with right shift operators correctly.
      */
     public static final int TEST_STATIC_FINAL_FIELD_1 = 2 >> 1;
 
     /**
-     * to test if it will handle static final field correctly.
+     * to test if it will handle static final String field with left shift operator and right shift operator correctly.
      */
     public static final String TEST_STATIC_FINAL_FIELD_2 = "<>?";
 }

[maven-javadoc-plugin] 02/03: change to use StringEscapeUtils in commons-text 1.3 also change the length check to escapedValue instead of raw value.

Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0f4ba75a4e6c5d507e4301e25cbaa9557804423f
Author: XenoAmess <xe...@gmail.com>
AuthorDate: Sat Aug 29 22:57:00 2020 +0800

    change to use StringEscapeUtils in commons-text 1.3 also change the length check to escapedValue instead of raw value.
---
 pom.xml                                                          | 5 +++++
 .../org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java | 9 +++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2d7edee..ca3c59f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -256,6 +256,11 @@ under the License.
       <version>3.8.1</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-text</artifactId>
+      <version>1.3</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpclient</artifactId>
       <version>4.5.13</version>
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
index c6e31e0..fac56cc 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
@@ -39,7 +39,7 @@ import com.thoughtworks.qdox.parser.ParseException;
 import com.thoughtworks.qdox.type.TypeResolver;
 
 import org.apache.commons.lang3.ClassUtils;
-import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.text.StringEscapeUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -1409,15 +1409,16 @@ public abstract class AbstractFixJavadocMojo
                 }
 
                 sb.append( "=\"" );
+                String escapedValue = StringEscapeUtils.escapeHtml4( value.toString() );
                 // reduce the size
                 // CHECKSTYLE_OFF: MagicNumber
-                if ( value.length() < 40 )
+                if ( escapedValue.length() < 40 )
                 {
-                    sb.append( StringEscapeUtils.escapeHtml4( value.toString() ) ).append( "\"" );
+                    sb.append( escapedValue ).append( "\"" );
                 }
                 else
                 {
-                    sb.append( StringEscapeUtils.escapeHtml4( value.toString() ), 0, 39 ).append( "\"{trunked}" );
+                    sb.append( escapedValue, 0, 39 ).append( "\"{trunked}" );
                 }
                 // CHECKSTYLE_ON: MagicNumber
             }

[maven-javadoc-plugin] 01/03: The fix operation wrongly generate illegal javadoc for static final fields.

Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 189fc54cdf173d0bdd36cc1cbde63b83280211da
Author: XenoAmess <xe...@gmail.com>
AuthorDate: Fri Aug 28 12:01:18 2020 +0800

    The fix operation wrongly generate illegal javadoc for static final fields.
---
 .../maven/plugins/javadoc/AbstractFixJavadocMojo.java     |  7 ++++---
 .../expected/src/main/java/fix/test/ClassWithJavadoc.java | 15 +++++++++++++++
 .../src/main/java/fix/test/ClassWithNoJavadoc.java        |  9 +++++++++
 .../fix-test/src/main/java/fix/test/ClassWithJavadoc.java | 15 +++++++++++++++
 .../src/main/java/fix/test/ClassWithNoJavadoc.java        |  6 ++++++
 5 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
index 1d98ada..c6e31e0 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
@@ -39,6 +39,7 @@ import com.thoughtworks.qdox.parser.ParseException;
 import com.thoughtworks.qdox.type.TypeResolver;
 
 import org.apache.commons.lang3.ClassUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -1381,7 +1382,7 @@ public abstract class AbstractFixJavadocMojo
                 Character.TYPE.toString() ) )
             {
                 sb.append( "=" );
-                sb.append( field.getInitializationExpression().trim() );
+                sb.append( StringEscapeUtils.escapeHtml4( field.getInitializationExpression().trim() ) );
             }
 
             if ( qualifiedName.equals( String.class.getName() ) )
@@ -1412,11 +1413,11 @@ public abstract class AbstractFixJavadocMojo
                 // CHECKSTYLE_OFF: MagicNumber
                 if ( value.length() < 40 )
                 {
-                    sb.append( value.toString() ).append( "\"" );
+                    sb.append( StringEscapeUtils.escapeHtml4( value.toString() ) ).append( "\"" );
                 }
                 else
                 {
-                    sb.append( value.toString(), 0, 39 ).append( "\"{trunked}" );
+                    sb.append( StringEscapeUtils.escapeHtml4( value.toString() ), 0, 39 ).append( "\"{trunked}" );
                 }
                 // CHECKSTYLE_ON: MagicNumber
             }
diff --git a/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java b/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java
index 174992f..0b5a374 100644
--- a/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java
+++ b/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java
@@ -451,6 +451,21 @@ public class ClassWithJavadoc
     {
         throw new Exception();
     }
+
+    /**
+     * to test if it will handle static final field correctly.
+     */
+    public static final int TEST_STATIC_FINAL_FIELD_0 = 1 << 2;
+
+    /**
+     * to test if it will handle static final field correctly.
+     */
+    public static final int TEST_STATIC_FINAL_FIELD_1 = 2 >> 1;
+
+    /**
+     * to test if it will handle static final field correctly.
+     */
+    public static final String TEST_STATIC_FINAL_FIELD_2 = "<>?";
 }
 
 /**
diff --git a/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithNoJavadoc.java b/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithNoJavadoc.java
index e2ff6a9..44d869e 100644
--- a/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithNoJavadoc.java
+++ b/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithNoJavadoc.java
@@ -267,6 +267,15 @@ public class ClassWithNoJavadoc
     {
         throw new Exception();
     }
+
+    /** Constant <code>TEST_STATIC_FINAL_FIELD_0=1 &lt;&lt; 2</code> */
+    public static final int TEST_STATIC_FINAL_FIELD_0 = 1 << 2;
+
+    /** Constant <code>TEST_STATIC_FINAL_FIELD_1=2 &gt;&gt; 1</code> */
+    public static final int TEST_STATIC_FINAL_FIELD_1 = 2 >> 1;
+
+    /** Constant <code>TEST_STATIC_FINAL_FIELD_2="&lt;&gt;?"</code> */
+    public static final String TEST_STATIC_FINAL_FIELD_2 = "<>?";
 }
 
 @SuppressWarnings("SameReturnValue")
diff --git a/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java b/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java
index f5c2f96..ab0d445 100644
--- a/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java
+++ b/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java
@@ -414,6 +414,21 @@ public class ClassWithJavadoc
     {
         throw new Exception();
     }
+
+    /**
+     * to test if it will handle static final field correctly.
+     */
+    public static final int TEST_STATIC_FINAL_FIELD_0 = 1 << 2;
+
+    /**
+     * to test if it will handle static final field correctly.
+     */
+    public static final int TEST_STATIC_FINAL_FIELD_1 = 2 >> 1;
+
+    /**
+     * to test if it will handle static final field correctly.
+     */
+    public static final String TEST_STATIC_FINAL_FIELD_2 = "<>?";
 }
 
 /**
diff --git a/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java b/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java
index fa4421c..5fddac7 100644
--- a/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java
+++ b/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java
@@ -170,6 +170,12 @@ public class ClassWithNoJavadoc
     {
         throw new Exception();
     }
+
+    public static final int TEST_STATIC_FINAL_FIELD_0 = 1 << 2;
+
+    public static final int TEST_STATIC_FINAL_FIELD_1 = 2 >> 1;
+
+    public static final String TEST_STATIC_FINAL_FIELD_2 = "<>?";
 }
 
 @SuppressWarnings("SameReturnValue")