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 2019/03/01 09:31:27 UTC

[maven-javadoc-plugin] 02/02: [MJAVADOC-580] javadoc:javadoc detects wrong java API link when running on openjdk 11.0.2

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

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

commit d2adefd7410cae0c76d5143c4bc7b6f9e1d1539c
Author: rfscholte <rf...@apache.org>
AuthorDate: Fri Mar 1 10:31:15 2019 +0100

    [MJAVADOC-580] javadoc:javadoc detects wrong java API link when running on openjdk 11.0.2
---
 .../MJAVADOC-580_detectLinks/invoker.properties    | 18 ++++++++
 src/it/projects/MJAVADOC-580_detectLinks/pom.xml   | 52 ++++++++++++++++++++++
 .../src/main/java/foo/Bar.java                     | 30 +++++++++++++
 .../MJAVADOC-580_detectLinks/test.properties       | 20 +++++++++
 .../MJAVADOC-580_detectLinks/verify.groovy         | 21 +++++++++
 .../maven/plugins/javadoc/AbstractJavadocMojo.java |  7 +--
 6 files changed, 145 insertions(+), 3 deletions(-)

diff --git a/src/it/projects/MJAVADOC-580_detectLinks/invoker.properties b/src/it/projects/MJAVADOC-580_detectLinks/invoker.properties
new file mode 100644
index 0000000..50090e3
--- /dev/null
+++ b/src/it/projects/MJAVADOC-580_detectLinks/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.debug=true
+invoker.goals=javadoc:javadoc
diff --git a/src/it/projects/MJAVADOC-580_detectLinks/pom.xml b/src/it/projects/MJAVADOC-580_detectLinks/pom.xml
new file mode 100644
index 0000000..257b003
--- /dev/null
+++ b/src/it/projects/MJAVADOC-580_detectLinks/pom.xml
@@ -0,0 +1,52 @@
+<?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.javadoc.it</groupId>
+  <artifactId>mjavadoc580</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  
+  <url>https://issues.apache.org/jira/browse/MJAVADOC-580</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>
+
+</project>
diff --git a/src/it/projects/MJAVADOC-580_detectLinks/src/main/java/foo/Bar.java b/src/it/projects/MJAVADOC-580_detectLinks/src/main/java/foo/Bar.java
new file mode 100644
index 0000000..d9304f5
--- /dev/null
+++ b/src/it/projects/MJAVADOC-580_detectLinks/src/main/java/foo/Bar.java
@@ -0,0 +1,30 @@
+package 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.io.IOException;
+
+public class Bar {
+
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello Bar" );
+    }
+}
diff --git a/src/it/projects/MJAVADOC-580_detectLinks/test.properties b/src/it/projects/MJAVADOC-580_detectLinks/test.properties
new file mode 100644
index 0000000..2ed10d0
--- /dev/null
+++ b/src/it/projects/MJAVADOC-580_detectLinks/test.properties
@@ -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.
+
+#ensure 'javadoc -J-version' is called
+maven.compiler.source=
+maven.compiler.target=
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-580_detectLinks/verify.groovy b/src/it/projects/MJAVADOC-580_detectLinks/verify.groovy
new file mode 100644
index 0000000..c296a4e
--- /dev/null
+++ b/src/it/projects/MJAVADOC-580_detectLinks/verify.groovy
@@ -0,0 +1,21 @@
+/*
+ * 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 buildLog = new File(basedir,'build.log')
+assert buildLog.readLines().any{ it ==~ /\[DEBUG\] Found Java API link: .*\/javase\/\d+\/docs\/api\// }
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 3c0ac16..bf5884a 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -6249,12 +6249,13 @@ public abstract class AbstractJavadocMojo
         }
         else if ( javaApiversion.isAtLeast( "11" ) )
         {
-            javaApiLink = String.format( "https://docs.oracle.com/en/java/javase/%s/docs/api/",
-                javaApiversion.getValue( 1 ) );
+            javaApiLink =
+                String.format( "https://docs.oracle.com/en/java/javase/%s/docs/api/", javaApiversion.getValue( 1 ) );
         }
         else if ( javaApiversion.asMajor().isAtLeast( "6" ) )
         {
-            javaApiLink = String.format( "https://docs.oracle.com/javase/%s/docs/api/", javaApiversion.asMajor() );
+            javaApiLink =
+                String.format( "https://docs.oracle.com/javase/%s/docs/api/", javaApiversion.asMajor().getValue( 1 ) );
         }
         else if ( javaApiversion.isAtLeast( "1.5" ) )
         {