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/05/10 18:59:24 UTC

[maven-javadoc-plugin] branch MJAVADOC-592 created (now 853ae11)

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

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


      at 853ae11  [MJAVADOC-592] detectJavaApiLink should also respect maven.compiler.source property

This branch includes the following new commits:

     new 853ae11  [MJAVADOC-592] detectJavaApiLink should also respect maven.compiler.source property

The 1 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] 01/01: [MJAVADOC-592] detectJavaApiLink should also respect maven.compiler.source property

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

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

commit 853ae1166770eb426dc4c12eea8eb103d59794e0
Author: rfscholte <rf...@apache.org>
AuthorDate: Mon May 10 20:59:04 2021 +0200

    [MJAVADOC-592] detectJavaApiLink should also respect maven.compiler.source property
---
 .../MJAVADOC-592_detectApiLink/invoker.properties  | 17 +++++++
 src/it/projects/MJAVADOC-592_detectApiLink/pom.xml | 53 ++++++++++++++++++++++
 .../src/main/java/foo/Bar.java                     | 30 ++++++++++++
 .../MJAVADOC-592_detectApiLink/verify.groovy       | 21 +++++++++
 .../maven/plugins/javadoc/AbstractJavadocMojo.java |  6 ++-
 5 files changed, 126 insertions(+), 1 deletion(-)

diff --git a/src/it/projects/MJAVADOC-592_detectApiLink/invoker.properties b/src/it/projects/MJAVADOC-592_detectApiLink/invoker.properties
new file mode 100644
index 0000000..3a8a738
--- /dev/null
+++ b/src/it/projects/MJAVADOC-592_detectApiLink/invoker.properties
@@ -0,0 +1,17 @@
+# 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:javadoc
diff --git a/src/it/projects/MJAVADOC-592_detectApiLink/pom.xml b/src/it/projects/MJAVADOC-592_detectApiLink/pom.xml
new file mode 100644
index 0000000..4806343
--- /dev/null
+++ b/src/it/projects/MJAVADOC-592_detectApiLink/pom.xml
@@ -0,0 +1,53 @@
+<?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>mjavadoc592</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  
+  <url>https://issues.apache.org/jira/browse/MJAVADOC-592</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <!-- maven-invoker-plugin passes maven.compiler.source as cli-property  -->
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.8.1</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-592_detectApiLink/src/main/java/foo/Bar.java b/src/it/projects/MJAVADOC-592_detectApiLink/src/main/java/foo/Bar.java
new file mode 100644
index 0000000..d9304f5
--- /dev/null
+++ b/src/it/projects/MJAVADOC-592_detectApiLink/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-592_detectApiLink/verify.groovy b/src/it/projects/MJAVADOC-592_detectApiLink/verify.groovy
new file mode 100644
index 0000000..0e75cf3
--- /dev/null
+++ b/src/it/projects/MJAVADOC-592_detectApiLink/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 options = new File(basedir,'target/site/apidocs/options')
+assert options.readLines().dropWhile{it!='-linkoffline'}.get(1).startsWith("'https://docs.oracle.com/javase/8/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 2d43182..4d59425 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -869,7 +869,7 @@ public abstract class AbstractJavadocMojo
      * Since <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/whatsnew-1.4.html#summary">Java
      * 1.4</a>.
      */
-    @Parameter( property = "source" )
+    @Parameter( property = "source", defaultValue = "${maven.compiler.source}" )
     private String source;
 
     /**
@@ -6511,6 +6511,10 @@ public abstract class AbstractJavadocMojo
         {
             javaApiversion = JavaVersion.parse( release );
         }
+        else if ( source != null && !source.isEmpty() )
+        {
+            javaApiversion = JavaVersion.parse( source );
+        }
         else
         {
             final String pluginId = "org.apache.maven.plugins:maven-compiler-plugin";