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 2018/12/15 19:22:05 UTC

[maven-javadoc-plugin] 01/01: [MJAVADOC-420] javadoc:fix duplicates lines

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

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

commit 28db4b08fc030036a138c36363b0fd2540a99e5f
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Dec 15 20:21:58 2018 +0100

    [MJAVADOC-420] javadoc:fix duplicates lines
---
 .../MJAVADOC-420_fixparam/invoker.properties       | 18 ++++++
 src/it/projects/MJAVADOC-420_fixparam/pom.xml      | 70 ++++++++++++++++++++++
 .../src/main/java/com/example/FirstBug.java        | 36 +++++++++++
 .../projects/MJAVADOC-420_fixparam/verify.groovy   | 25 ++++++++
 .../plugins/javadoc/AbstractFixJavadocMojo.java    |  6 +-
 5 files changed, 153 insertions(+), 2 deletions(-)

diff --git a/src/it/projects/MJAVADOC-420_fixparam/invoker.properties b/src/it/projects/MJAVADOC-420_fixparam/invoker.properties
new file mode 100644
index 0000000..52b0251
--- /dev/null
+++ b/src/it/projects/MJAVADOC-420_fixparam/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals=javadoc:fix compile
diff --git a/src/it/projects/MJAVADOC-420_fixparam/pom.xml b/src/it/projects/MJAVADOC-420_fixparam/pom.xml
new file mode 100644
index 0000000..75f71ba
--- /dev/null
+++ b/src/it/projects/MJAVADOC-420_fixparam/pom.xml
@@ -0,0 +1,70 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
+  <artifactId>mjavadoc434</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  
+  <url>https://issues.apache.org/jira/browse/MJAVADOC-434</url>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-javadoc-plugin</artifactId>
+          <version>@project.version@</version>
+          <configuration>
+            <detectLinks>true</detectLinks>
+            <force>true</force>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context</artifactId>
+      <version>3.2.2.RELEASE</version>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-webmvc</artifactId>
+      <version>3.2.2.RELEASE</version>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.7.5</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <scope>provided</scope>
+      <version>2.5</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/src/it/projects/MJAVADOC-420_fixparam/src/main/java/com/example/FirstBug.java b/src/it/projects/MJAVADOC-420_fixparam/src/main/java/com/example/FirstBug.java
new file mode 100644
index 0000000..cfd1cb4
--- /dev/null
+++ b/src/it/projects/MJAVADOC-420_fixparam/src/main/java/com/example/FirstBug.java
@@ -0,0 +1,36 @@
+package com.example;
+
+/*
+ * 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.
+ */
+
+/**
+ * <p>FirstBug class.</p>
+ */
+public class FirstBug {
+
+    /**
+     * <p>mymethod.</p>
+     *
+     * @param param a {@link java.lang.String} object.
+     * @param paramSecond a {@link java.lang.String} object.
+     */
+    public void mymethod( String param, String paramSecond ) {
+        
+    }
+}
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-420_fixparam/verify.groovy b/src/it/projects/MJAVADOC-420_fixparam/verify.groovy
new file mode 100644
index 0000000..0caa34d
--- /dev/null
+++ b/src/it/projects/MJAVADOC-420_fixparam/verify.groovy
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+def file = new File( basedir, 'src/main/java/com/example/FirstBug.java' );
+
+assert file.exists()
+
+// assert that javadoc of class correctly contains link, just like method details
+assert 1 == file.text.count('@param paramSecond a {@link java.lang.String} object.')
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 f2439d6..6922813 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
@@ -3301,8 +3301,10 @@ public abstract class AbstractFixJavadocMojo
         while ( ( line = lr.readLine() ) != null )
         {
             String l = StringUtils.removeDuplicateWhitespace( line.trim() );
-            if ( l.startsWith( "* @" + docletTag.getName() + " " + paramValue ) || l.startsWith(
-                "*@" + docletTag.getName() + " " + paramValue ) )
+            if ( l.startsWith( "* @" + docletTag.getName() + " " + paramValue + " " )
+                || l.startsWith( "*@" + docletTag.getName() + " " + paramValue + " " )
+                || l.equals( "* @" + docletTag.getName() + " " + paramValue )
+                || l.equals( "*@" + docletTag.getName() + " " + paramValue ) )
             {
                 if ( fixTag( LINK_TAG ) )
                 {