[Git][java-team/maven-javadoc-plugin][upstream] New upstream version 3.0.1
Emmanuel Bourg
gitlab at salsa.debian.org
Mon Jul 30 10:04:47 BST 2018
Emmanuel Bourg pushed to branch upstream at Debian Java Maintainers / maven-javadoc-plugin
Commits:
0e82ba40 by Emmanuel Bourg at 2018-07-30T07:56:59Z
New upstream version 3.0.1
- - - - -
30 changed files:
- + .gitignore
- + CONTRIBUTING.md
- + Jenkinsfile
- + README.md
- pom.xml
- src/it/projects/MJAVADOC-325/verify.bsh
- + src/it/projects/MJAVADOC-427/invoker.properties
- + src/it/projects/MJAVADOC-427/pom.xml
- + src/it/projects/MJAVADOC-427/src/main/java/mjavadoc427/App.java
- + src/it/projects/MJAVADOC-427/verify.groovy
- + src/it/projects/MJAVADOC-508/invoker.properties
- + src/it/projects/MJAVADOC-508/pom.xml
- + src/it/projects/MJAVADOC-508/src/main/java/foo/bar/ALotOfLinkTags.java
- src/it/projects/detectLinks/pom.xml
- src/it/projects/detectLinks/verify.bsh
- src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
- src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
- src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java
- src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
- src/main/java/org/apache/maven/plugins/javadoc/JavadocVersion.java
- + src/main/java/org/apache/maven/plugins/javadoc/SystemUtils.java
- src/main/java/org/apache/maven/plugins/javadoc/resolver/SourceResolverConfig.java
- src/main/mdo/javadocOptions.mdo
- src/site/xdoc/download.xml.vm
- src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
- src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java
- src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
- src/test/java/org/apache/maven/plugins/javadoc/JavadocUtilTest.java
- src/test/resources/unit/docfiles-with-java-test/src/main/test/App.java
- src/test/resources/unit/docfiles-with-java-test/src/main/test/doc-files/App.java
Changes:
=====================================
.gitignore
=====================================
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+target/
+.project
+.classpath
+.settings/
+.svn/
+bin/
+# Intellij
+*.ipr
+*.iml
+.idea
+out/
+.DS_Store
+/bootstrap
+/dependencies.xml
+.java-version
+/javadoc-options-javadoc-resources.xml
+.checkstyle
=====================================
CONTRIBUTING.md
=====================================
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,91 @@
+<!---
+ 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.
+-->
+Contributing to Apache Maven JavaDoc Plugin
+======================
+
+You have found a bug or you have an idea for a cool new feature? Contributing
+code is a great way to give something back to the open source community. Before
+you dig right into the code, there are a few guidelines that we need
+contributors to follow so that we can have a chance of keeping on top of
+things.
+
+Some of the ideas are documented in the [Maven Wiki][maven-wiki]
+which might be interesting to read and for further discussion.
+
+Getting Started
+---------------
+
++ Make sure you have a [JIRA account](https://issues.apache.org/jira/).
++ Make sure you have a [GitHub account](https://github.com/signup/free).
++ If you're planning to implement a new feature, it makes sense to discuss your changes
+ on the [dev list](https://maven.apache.org/mail-lists.html) first.
+ This way you can make sure you're not wasting your time on something that isn't
+ considered to be in Apache Maven's scope.
++ Submit a ticket for your issue, assuming one does not already exist.
+ + Clearly describe the issue, including steps to reproduce when it is a bug.
+ + Make sure you fill in the earliest version that you know has the issue.
++ Fork the repository on GitHub.
+
+Making and Submitting Changes
+--------------
+
+We accept Pull Requests via GitHub. The [developer mailing list][dev-ml-list] is the
+main channel of communication for contributors.
+There are some guidelines which will make applying PRs easier for us:
++ Create a topic branch from where you want to base your work (this is usually the master branch).
+ Push your changes to a topic branch in your fork of the repository.
++ Make commits of logical units.
++ Respect the original code style: by using the same [codestyle][code-style],
+ patches should only highlight the actual difference, not being disturbed by any formatting issues:
+ + Only use spaces for indentation.
+ + Create minimal diffs - disable on save actions like reformat source code or organize imports.
+ If you feel the source code should be reformatted, create a separate PR for this change.
+ + Check for unnecessary whitespace with `git diff --check` before committing.
++ Make sure your commit messages are in the proper format. Your commit message should contain the key of the JIRA issue.
+```
+[MJAVADOC-XXX] - Subject of the JIRA Ticket
+ Optional supplemental description.
+```
++ Make sure you have added the necessary tests (JUnit/IT) for your changes.
++ Run all the tests with `mvn -Prun-its verify` to assure nothing else was accidentally broken.
++ Submit a pull request to the repository in the Apache organization.
++ Update your JIRA ticket and include a link to the pull request in the ticket.
+
+If you plan to contribute on a regular basis, please consider filing a [contributor license agreement][cla].
+
+Making Trivial Changes
+----------------------
+
+For changes of a trivial nature to comments and documentation, it is not always
+necessary to create a new ticket in JIRA. In this case, it is appropriate to
+start the first line of a commit with '(doc)' instead of a ticket number.
+
+Additional Resources
+--------------------
+
++ [Contributing patches](https://maven.apache.org/guides/development/guide-maven-development.html#Creating_and_submitting_a_patch)
++ [Apache Maven JavaDoc JIRA project page](https://issues.apache.org/jira/projects/MJAVADOC/)
++ [Contributor License Agreement][cla]
++ [General GitHub documentation](https://help.github.com/)
++ [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
++ [Apache Maven Twitter Account](https://twitter.com/ASFMavenProject)
++ #Maven IRC channel on freenode.org
+
+[dev-ml-list]: https://maven.apache.org/mail-lists.html
+[code-style]: https://maven.apache.org/developers/conventions/code.html
+[cla]: https://www.apache.org/licenses/#clas
+[maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index
=====================================
Jenkinsfile
=====================================
--- /dev/null
+++ b/Jenkinsfile
@@ -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.
+ */
+
+asfMavenTlpStdBuild(jdk:[7,8,9])
=====================================
README.md
=====================================
--- /dev/null
+++ b/README.md
@@ -0,0 +1,99 @@
+<!---
+ 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.
+-->
+Contributing to Apache Maven JavaDoc Plugin
+======================
+
+[![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license]
+[![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-javadoc-plugin.svg?label=Maven%20Central)](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.apache.maven.plugins%22%20AND%20a%3A%22maven-javadoc-plugin%22)
+[![Jenkins Status](https://img.shields.io/jenkins/s/https/builds.apache.org/job/maven-box/job/maven-javadoc-plugin/job/master.svg?style=flat-square)][build]
+[![Jenkins tests](https://img.shields.io/jenkins/t/https/builds.apache.org/job/maven-box/job/maven-javadoc-plugin/job/master.svg?style=flat-square)][test-results]
+
+You have found a bug or you have an idea for a cool new feature? Contributing
+code is a great way to give something back to the open source community. Before
+you dig right into the code, there are a few guidelines that we need
+contributors to follow so that we can have a chance of keeping on top of
+things.
+
+Some of the ideas are documented in the [Maven Wiki][maven-wiki]
+which might be interesting to read and for further discussion.
+
+Getting Started
+---------------
+
++ Make sure you have a [JIRA account](https://issues.apache.org/jira/).
++ Make sure you have a [GitHub account](https://github.com/signup/free).
++ If you're planning to implement a new feature, it makes sense to discuss your changes
+ on the [dev list](https://maven.apache.org/mail-lists.html) first.
+ This way you can make sure you're not wasting your time on something that isn't
+ considered to be in Apache Maven's scope.
++ Submit a ticket for your issue, assuming one does not already exist.
+ + Clearly describe the issue, including steps to reproduce when it is a bug.
+ + Make sure you fill in the earliest version that you know has the issue.
++ Fork the repository on GitHub.
+
+Making and Submitting Changes
+--------------
+
+We accept Pull Requests via GitHub. The [developer mailing list][dev-ml-list] is the
+main channel of communication for contributors.
+There are some guidelines which will make applying PRs easier for us:
++ Create a topic branch from where you want to base your work (this is usually the master branch).
+ Push your changes to a topic branch in your fork of the repository.
++ Make commits of logical units.
++ Respect the original code style: by using the same [codestyle][code-style],
+ patches should only highlight the actual difference, not being disturbed by any formatting issues:
+ + Only use spaces for indentation.
+ + Create minimal diffs - disable on save actions like reformat source code or organize imports.
+ If you feel the source code should be reformatted, create a separate PR for this change.
+ + Check for unnecessary whitespace with `git diff --check` before committing.
++ Make sure your commit messages are in the proper format. Your commit message should contain the key of the JIRA issue.
+```
+[MJAVADOC-XXX] - Subject of the JIRA Ticket
+ Optional supplemental description.
+```
++ Make sure you have added the necessary tests (JUnit/IT) for your changes.
++ Run all the tests with `mvn -Prun-its verify` to assure nothing else was accidentally broken.
++ Submit a pull request to the repository in the Apache organization.
++ Update your JIRA ticket and include a link to the pull request in the ticket.
+
+If you plan to contribute on a regular basis, please consider filing a [contributor license agreement][cla].
+
+Making Trivial Changes
+----------------------
+
+For changes of a trivial nature to comments and documentation, it is not always
+necessary to create a new ticket in JIRA. In this case, it is appropriate to
+start the first line of a commit with '(doc)' instead of a ticket number.
+
+Additional Resources
+--------------------
+
++ [Contributing patches](https://maven.apache.org/guides/development/guide-maven-development.html#Creating_and_submitting_a_patch)
++ [Apache Maven JavaDoc JIRA project page](https://issues.apache.org/jira/projects/MJAVADOC/)
++ [Contributor License Agreement][cla]
++ [General GitHub documentation](https://help.github.com/)
++ [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
++ [Apache Maven Twitter Account](https://twitter.com/ASFMavenProject)
++ #Maven IRC channel on freenode.org
+
+[license]: https://www.apache.org/licenses/LICENSE-2.0
+[dev-ml-list]: https://maven.apache.org/mail-lists.html
+[code-style]: https://maven.apache.org/developers/conventions/code.html
+[cla]: https://www.apache.org/licenses/#clas
+[maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index
+[test-results]: https://builds.apache.org/job/maven-box/job/maven-javadoc-plugin/job/master/lastCompletedBuild/testReport/
+[build]: https://builds.apache.org/job/maven-box/job/maven-javadoc-plugin/job/master/
=====================================
pom.xml
=====================================
--- a/pom.xml
+++ b/pom.xml
@@ -25,12 +25,12 @@ under the License.
<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
- <version>30</version>
+ <version>31</version>
<relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
</parent>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1</version>
<packaging>maven-plugin</packaging>
<name>Apache Maven Javadoc Plugin</name>
@@ -45,14 +45,19 @@ under the License.
</prerequisites>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/maven/plugins/tags/maven-javadoc-plugin-3.0.0</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/plugins/tags/maven-javadoc-plugin-3.0.0</developerConnection>
- <url>http://svn.apache.org/viewvc/maven/plugins/tags/maven-javadoc-plugin-3.0.0</url>
+ <connection>scm:git:https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git</connection>
+ <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git</developerConnection>
+ <url>https://github.com/apache/maven-javadoc-plugin/tree/${project.scm.tag}</url>
+ <tag>maven-javadoc-plugin-3.0.1</tag>
</scm>
<issueManagement>
<system>jira</system>
<url>https://issues.apache.org/jira/browse/MJAVADOC</url>
</issueManagement>
+ <ciManagement>
+ <system>Jenkins</system>
+ <url>https://builds.apache.org/job/maven-box/job/maven-javadoc-plugin/</url>
+ </ciManagement>
<distributionManagement>
<site>
<id>apache.website</id>
@@ -163,12 +168,12 @@ under the License.
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-archiver</artifactId>
- <version>3.1.1</version>
+ <version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-invoker</artifactId>
- <version>2.2</version>
+ <version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
@@ -229,12 +234,12 @@ under the License.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-java</artifactId>
- <version>0.9.5</version>
+ <version>0.9.8</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
- <version>3.4</version>
+ <version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@@ -244,12 +249,16 @@ under the License.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interactivity-api</artifactId>
- <version>1.0-alpha-4</version>
+ <version>1.0-alpha-6</version>
<exclusions>
<exclusion>
<groupId>plexus</groupId>
<artifactId>plexus-utils</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
</exclusions>
</dependency>
@@ -396,6 +405,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
+ <version>2.21.0</version>
<configuration>
<systemProperties>
<property>
@@ -403,6 +413,9 @@ under the License.
<value>${maven.home}</value>
</property>
</systemProperties>
+ <environmentVariables>
+ <JENKINS_MAVEN_AGENT_DISABLED>true</JENKINS_MAVEN_AGENT_DISABLED>
+ </environmentVariables>
</configuration>
</plugin>
</plugins>
@@ -431,6 +444,9 @@ under the License.
<filterProperties>
<mrm.3rdparty.url>${mrm.3rdparty.url}</mrm.3rdparty.url>
</filterProperties>
+ <environmentVariables>
+ <JENKINS_MAVEN_AGENT_DISABLED>true</JENKINS_MAVEN_AGENT_DISABLED>
+ </environmentVariables>
</configuration>
</plugin>
<plugin>
=====================================
src/it/projects/MJAVADOC-325/verify.bsh
=====================================
--- a/src/it/projects/MJAVADOC-325/verify.bsh
+++ b/src/it/projects/MJAVADOC-325/verify.bsh
@@ -30,7 +30,7 @@ if ( !optionsFile.exists() )
}
String optionsContent = FileUtils.fileRead( optionsFile );
-String javaApiLink = "'http://docs.oracle.com/javase/1,5,0/docs/api'";
+String javaApiLink = "'https://docs.oracle.com/javase/1.5.0/docs/api'";
if ( !optionsContent.contains( javaApiLink ) )
{
=====================================
src/it/projects/MJAVADOC-427/invoker.properties
=====================================
--- /dev/null
+++ b/src/it/projects/MJAVADOC-427/invoker.properties
@@ -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.
+
+invoker.goals=clean javadoc:javadoc
+
+# slf4j javadoc is hosted on https site with a "let's encrypt" certificate, signed by IdenTrust only trusted since 8u101 (JDK-8154757)
+invoker.java.version = 1.8.0.101+
=====================================
src/it/projects/MJAVADOC-427/pom.xml
=====================================
--- /dev/null
+++ b/src/it/projects/MJAVADOC-427/pom.xml
@@ -0,0 +1,61 @@
+<?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>mjavadoc-427</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <url>https://issues.apache.org/jira/browse/MJAVADOC-427</url>
+ <description>Tests that the plugin follows redirects</description>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <!-- url of slf4j api is http, and javadoc is redirected to https -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.12</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>@pom.version@</version>
+ <configuration>
+ <detectLinks>true</detectLinks>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
=====================================
src/it/projects/MJAVADOC-427/src/main/java/mjavadoc427/App.java
=====================================
--- /dev/null
+++ b/src/it/projects/MJAVADOC-427/src/main/java/mjavadoc427/App.java
@@ -0,0 +1,35 @@
+package mjavadoc427;
+
+/*
+ * 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 org.slf4j.LoggerFactory;
+
+/**
+ * Link to slf4j {@link LoggerFactory}.
+ */
+public class App
+{
+
+ public LoggerFactory getLoggerFactory()
+ {
+ return null;
+ }
+
+}
=====================================
src/it/projects/MJAVADOC-427/verify.groovy
=====================================
--- /dev/null
+++ b/src/it/projects/MJAVADOC-427/verify.groovy
@@ -0,0 +1,26 @@
+/*
+ * 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, 'target/site/apidocs/mjavadoc427/App.html' );
+
+assert file.exists()
+
+// assert that javadoc of class correctly contains link, just like method details
+assert file.text =~ /Link to slf4j <a href=".*?".*?><code>LoggerFactory<\/code><\/a>/
+assert file.text =~ /<pre>public.*?<a href=".*?".*?>LoggerFactory<\/a>.*?getLoggerFactory.*?\(\)<\/pre>/
=====================================
src/it/projects/MJAVADOC-508/invoker.properties
=====================================
--- /dev/null
+++ b/src/it/projects/MJAVADOC-508/invoker.properties
@@ -0,0 +1,19 @@
+# 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=clean javadoc:javadoc
+invoker.buildResult = failure
=====================================
src/it/projects/MJAVADOC-508/pom.xml
=====================================
--- /dev/null
+++ b/src/it/projects/MJAVADOC-508/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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
+ <artifactId>mjavadoc-508</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>@pom.version@</version>
+ <configuration>
+ <failOnWarnings>true</failOnWarnings>
+ <serialwarn>true</serialwarn>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
=====================================
src/it/projects/MJAVADOC-508/src/main/java/foo/bar/ALotOfLinkTags.java
=====================================
--- /dev/null
+++ b/src/it/projects/MJAVADOC-508/src/main/java/foo/bar/ALotOfLinkTags.java
@@ -0,0 +1,37 @@
+package foo.bar;
+
+/*
+ * 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.Serializable;
+import java.util.HashSet;
+import java.util.*;
+
+public class ALotOfLinkTags
+ implements Serializable
+{
+ public int field; // intentionally not marked @serial to cause a javadoc warning
+
+ /**
+ */
+ public boolean aMethod( String[] args )
+ {
+ return true;
+ }
+}
=====================================
src/it/projects/detectLinks/pom.xml
=====================================
--- a/src/it/projects/detectLinks/pom.xml
+++ b/src/it/projects/detectLinks/pom.xml
@@ -53,8 +53,9 @@
<!-- unknown apidocs link -->
<dependency>
<groupId>org.apache.maven</groupId>
- <artifactId>maven-script-marmalade</artifactId>
- <version>2.0-beta-2</version>
+ <artifactId>maven-script</artifactId>
+ <version>2.2.1</version>
+ <type>pom</type>
</dependency>
</dependencies>
=====================================
src/it/projects/detectLinks/verify.bsh
=====================================
--- a/src/it/projects/detectLinks/verify.bsh
+++ b/src/it/projects/detectLinks/verify.bsh
@@ -69,7 +69,7 @@ try
System.err.println( "-link not added: " + options1 );
return false;
}
- if ( !contentOptions1.substring( link1 ).contains( "http://commons.apache.org/lang/apidocs" ) )
+ if ( !contentOptions1.substring( link1 ).contains( "commons.apache.org" ) )
{
System.err.println( "link for commons-lang not added: " + options1 );
if ( !log.contains( "Error fetching link: http://commons.apache.org/lang/apidocs" ) )
@@ -77,7 +77,7 @@ try
return false;
}
}
- if ( !contentOptions1.substring( link1 ).contains( "http://junit.org/apidocs" ) )
+ if ( !contentOptions1.substring( link1 ).contains( "junit.org" ) )
{
System.err.println( "link for junit not added: " + options1 );
if ( !log.contains( "Error fetching link: http://junit.org/apidocs" ) )
@@ -108,7 +108,7 @@ try
System.err.println( "-link not added: " + options2 );
return false;
}
- if ( !contentOptions2.substring( link2 ).contains( "http://commons.apache.org/lang/apidocs" ) )
+ if ( !contentOptions2.substring( link2 ).contains( "commons.apache.org" ) )
{
System.err.println( "link for commons-lang not added: " + options2 );
if ( !log.contains( "Error fetching link: http://commons.apache.org/lang/apidocs" ) )
@@ -116,7 +116,7 @@ try
return false;
}
}
- if ( !contentOptions2.substring( link2 ).contains( "http://junit.org/apidocs" ) )
+ if ( !contentOptions2.substring( link2 ).contains( "junit.org" ) )
{
System.err.println( "link for junit not added: " + options2 );
if ( !log.contains( "Error fetching link: http://junit.org/apidocs" ) )
=====================================
src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
=====================================
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
@@ -86,7 +86,7 @@ import java.util.regex.Pattern;
/**
* Abstract class to fix Javadoc documentation and tags in source files.
- * <br/>
+ * <br>
* See <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#wheretags">Where Tags
* Can Be Used</a>.
*
@@ -3681,7 +3681,7 @@ public abstract class AbstractFixJavadocMojo
*/
private List<String> unknownsTags;
- public JavaEntityTags( JavaAnnotatedElement entity, boolean isJavaMethod )
+ JavaEntityTags( JavaAnnotatedElement entity, boolean isJavaMethod )
{
this.entity = entity;
this.isJavaMethod = isJavaMethod;
=====================================
src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
=====================================
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -19,49 +19,7 @@ package org.apache.maven.plugins.javadoc;
* under the License.
*/
-import static org.apache.maven.plugins.javadoc.JavadocUtil.isEmpty;
-import static org.apache.maven.plugins.javadoc.JavadocUtil.isNotEmpty;
-import static org.apache.maven.plugins.javadoc.JavadocUtil.toList;
-import static org.apache.maven.plugins.javadoc.JavadocUtil.toRelative;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import org.apache.commons.lang3.ClassUtils;
-import org.apache.commons.lang3.JavaVersion;
-import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.handler.ArtifactHandler;
@@ -126,6 +84,7 @@ import org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelecto
import org.codehaus.plexus.languages.java.jpms.LocationManager;
import org.codehaus.plexus.languages.java.jpms.ResolvePathsRequest;
import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
@@ -137,6 +96,46 @@ import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
import org.codehaus.plexus.util.xml.Xpp3Dom;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static org.apache.maven.plugins.javadoc.JavadocUtil.toRelative;
+import static org.apache.maven.plugins.javadoc.JavadocUtil.toList;
+import static org.apache.maven.plugins.javadoc.JavadocUtil.isEmpty;
+import static org.apache.maven.plugins.javadoc.JavadocUtil.isNotEmpty;
+
/**
* Base class with majority of Javadoc functionalities.
*
@@ -256,7 +255,7 @@ public abstract class AbstractJavadocMojo
*
* @since 2.1
*/
- private static final JavadocVersion SINCE_JAVADOC_1_4 = JavadocVersion.parse( "1.4" );
+ private static final JavaVersion SINCE_JAVADOC_1_4 = JavaVersion.parse( "1.4" );
/**
* For Javadoc options appears since Java 1.4.2.
@@ -266,7 +265,7 @@ public abstract class AbstractJavadocMojo
*
* @since 2.1
*/
- private static final JavadocVersion SINCE_JAVADOC_1_4_2 = JavadocVersion.parse( "1.4.2" );
+ private static final JavaVersion SINCE_JAVADOC_1_4_2 = JavaVersion.parse( "1.4.2" );
/**
* For Javadoc options appears since Java 5.0.
@@ -276,7 +275,7 @@ public abstract class AbstractJavadocMojo
*
* @since 2.1
*/
- private static final JavadocVersion SINCE_JAVADOC_1_5 = JavadocVersion.parse( "1.5" );
+ private static final JavaVersion SINCE_JAVADOC_1_5 = JavaVersion.parse( "1.5" );
/**
* For Javadoc options appears since Java 6.0.
@@ -285,7 +284,7 @@ public abstract class AbstractJavadocMojo
*
* @since 2.4
*/
- private static final JavadocVersion SINCE_JAVADOC_1_6 = JavadocVersion.parse( "1.6" );
+ private static final JavaVersion SINCE_JAVADOC_1_6 = JavaVersion.parse( "1.6" );
/**
* For Javadoc options appears since Java 8.0.
@@ -294,13 +293,12 @@ public abstract class AbstractJavadocMojo
*
* @since 3.0.0
*/
- private static final JavadocVersion SINCE_JAVADOC_1_8 = JavadocVersion.parse( "1.8" );
+ private static final JavaVersion SINCE_JAVADOC_1_8 = JavaVersion.parse( "1.8" );
/**
*
*/
- // JAVA_VERSION can have -ea suffix, which is not supported (yet)
- private static final JavadocVersion JAVA_VERSION = JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION );
+ private static final JavaVersion JAVA_VERSION = JavaVersion.JAVA_SPECIFICATION_VERSION;
// ----------------------------------------------------------------------
// Mojo components
@@ -490,7 +488,7 @@ public abstract class AbstractJavadocMojo
/**
* Version of the Javadoc Tool executable to use.
*/
- private JavadocVersion javadocRuntimeVersion;
+ private JavaVersion javadocRuntimeVersion;
/**
* Specifies whether the Javadoc generation should be skipped.
@@ -508,11 +506,20 @@ public abstract class AbstractJavadocMojo
@Parameter( property = "maven.javadoc.failOnError", defaultValue = "true" )
protected boolean failOnError;
+
+ /**
+ * Specifies if the build will fail if there are warning during javadoc execution or not.
+ *
+ * @since 3.0.1
+ */
+ @Parameter( property = "maven.javadoc.failOnWarnings", defaultValue = "false" )
+ protected boolean failOnWarnings;
+
/**
* Specifies to use the
* <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#standard">
* options provided by the Standard Doclet</a> for a custom doclet.
- * <br/>
+ * <br>
* Example:
* <pre>
* <docletArtifacts>
@@ -1121,7 +1128,7 @@ public abstract class AbstractJavadocMojo
/**
* Creates links to existing javadoc-generated documentation of external referenced classes.
- * <br/>
+ * <br>
* <b>Notes</b>:
* <ol>
* <li>only used if {@link #isOffline} is set to <code>false</code>.</li>
@@ -1281,9 +1288,8 @@ public abstract class AbstractJavadocMojo
/**
* Omits the class/interface hierarchy pages from the generated docs.
- * <br/>
- * See <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#notree">notree</a>.
- * <br/>
+ * <br>
+ * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#notree">notree</a> option
*/
@Parameter( property = "notree", defaultValue = "false" )
private boolean notree;
@@ -1307,18 +1313,16 @@ public abstract class AbstractJavadocMojo
* <br/>
* <b>Note</b>: if {@link #detectOfflineLinks} is defined, the offline links between the project modules are
* automatically added if the goal is calling in a non-aggregator way.
- * <br/>
- * See <a href="./apidocs/org/apache/maven/plugin/javadoc/options/OfflineLink.html">Javadoc</a>.
- * <br/>
+ * <br>
+ * @see <a href="./apidocs/org/apache/maven/plugin/javadoc/options/OfflineLink.html">Javadoc</a>.
*/
@Parameter( property = "offlineLinks" )
private OfflineLink[] offlineLinks;
/**
* Specifies the destination directory where javadoc saves the generated HTML files.
- * <br/>
- * See <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#d">d</a>.
- * <br/>
+ * <br>
+ * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#d">d</a> option
*/
@Parameter( property = "destDir", alias = "destDir", defaultValue = "${project.build.directory}/apidocs",
required = true )
@@ -1339,8 +1343,7 @@ public abstract class AbstractJavadocMojo
/**
* Generates compile-time warnings for missing serial tags.
* <br/>
- * See <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#serialwarn">serialwarn</a>
- * <br/>
+ * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#serialwarn">serialwarn</a> option
*/
@Parameter( property = "serialwarn", defaultValue = "false" )
private boolean serialwarn;
@@ -2223,7 +2226,7 @@ public abstract class AbstractJavadocMojo
*
* @return a Collection of the project absolute source paths as <code>String</code>
* @throws MavenReportException {@link MavenReportException}
- * @see JavadocUtil#pruneDirs(MavenProject, List)
+ * @see JavadocUtil#pruneDirs(MavenProject, Collection)
*/
protected Map<String, Collection<String>> getSourcePaths()
throws MavenReportException
@@ -2325,7 +2328,7 @@ public abstract class AbstractJavadocMojo
/**
* Override this method to customize the configuration for resolving dependency sources. The default
* behavior enables the resolution of -sources jar files.
- * @param config {@linke SourceResolverConfig}
+ * @param config {@link SourceResolverConfig}
* @return {@link SourceResolverConfig}
*/
protected SourceResolverConfig configureDependencySourceResolution( final SourceResolverConfig config )
@@ -2685,7 +2688,7 @@ public abstract class AbstractJavadocMojo
/**
* @param dependency {@link Dependency}
* @return {@link Artifact}
- * @throws MavenReportException
+ * @throws MavenReportException when artifact could not be resolved
*/
public Artifact resolveDependency( Dependency dependency )
throws MavenReportException
@@ -3154,7 +3157,7 @@ public abstract class AbstractJavadocMojo
links.addAll( getDependenciesLinks() );
- return links;
+ return followLinks( links );
}
private Set<Group> collectGroups()
@@ -3680,7 +3683,7 @@ public abstract class AbstractJavadocMojo
}
// For Apple's JDK 1.6.x (and older?) on Mac OSX
// CHECKSTYLE_OFF: MagicNumber
- else if ( SystemUtils.IS_OS_MAC_OSX && !SystemUtils.isJavaVersionAtLeast( JavaVersion.JAVA_1_7 ) )
+ else if ( SystemUtils.IS_OS_MAC_OSX && !JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "1.7" ) )
// CHECKSTYLE_ON: MagicNumber
{
javadocExe = new File( SystemUtils.getJavaHome() + File.separator + "bin", javadocCommand );
@@ -3731,7 +3734,7 @@ public abstract class AbstractJavadocMojo
private void setFJavadocVersion( File jExecutable )
throws MavenReportException
{
- JavadocVersion jVersion;
+ JavaVersion jVersion;
try
{
jVersion = JavadocUtil.getJavadocVersion( jExecutable );
@@ -3768,14 +3771,14 @@ public abstract class AbstractJavadocMojo
{
try
{
- javadocRuntimeVersion = JavadocVersion.parse( javadocVersion );
+ javadocRuntimeVersion = JavaVersion.parse( javadocVersion );
}
catch ( NumberFormatException e )
{
throw new MavenReportException( "Unable to parse javadoc version: " + e.getMessage(), e );
}
- if ( javadocRuntimeVersion != jVersion && getLog().isWarnEnabled() )
+ if ( javadocRuntimeVersion.compareTo( jVersion ) != 0 && getLog().isWarnEnabled() )
{
getLog().warn( "Are you sure about the <javadocVersion/> parameter? It seems to be " + jVersion );
}
@@ -3793,7 +3796,7 @@ public abstract class AbstractJavadocMojo
* @return <code>true</code> if the javadoc version is equal or greater than the
* required version
*/
- private boolean isJavaDocVersionAtLeast( JavadocVersion requiredVersion )
+ private boolean isJavaDocVersionAtLeast( JavaVersion requiredVersion )
{
return JAVA_VERSION.compareTo( requiredVersion ) >= 0;
}
@@ -3825,7 +3828,7 @@ public abstract class AbstractJavadocMojo
* @see #addArgIf(java.util.List, boolean, String)
* @see #isJavaDocVersionAtLeast(float)
*/
- private void addArgIf( List<String> arguments, boolean b, String value, JavadocVersion requiredJavaVersion )
+ private void addArgIf( List<String> arguments, boolean b, String value, JavaVersion requiredJavaVersion )
{
if ( b )
{
@@ -3876,7 +3879,7 @@ public abstract class AbstractJavadocMojo
* @see #isJavaDocVersionAtLeast(float)
*/
private void addArgIfNotEmpty( List<String> arguments, String key, String value, boolean repeatKey,
- boolean splitValue, JavadocVersion requiredJavaVersion )
+ boolean splitValue, JavaVersion requiredJavaVersion )
{
if ( StringUtils.isNotEmpty( value ) )
{
@@ -3969,7 +3972,7 @@ public abstract class AbstractJavadocMojo
* @see #addArgIfNotEmpty(java.util.List, String, String, float, boolean)
*/
private void addArgIfNotEmpty( List<String> arguments, String key, String value,
- JavadocVersion requiredJavaVersion )
+ JavaVersion requiredJavaVersion )
{
addArgIfNotEmpty( arguments, key, value, requiredJavaVersion, false );
}
@@ -3986,7 +3989,7 @@ public abstract class AbstractJavadocMojo
* @see #addArgIfNotEmpty(java.util.List, String, String)
* @see #isJavaDocVersionAtLeast(float)
*/
- private void addArgIfNotEmpty( List<String> arguments, String key, String value, JavadocVersion requiredJavaVersion,
+ private void addArgIfNotEmpty( List<String> arguments, String key, String value, JavaVersion requiredJavaVersion,
boolean repeatKey )
{
if ( StringUtils.isNotEmpty( value ) )
@@ -5321,6 +5324,11 @@ public abstract class AbstractJavadocMojo
getLog().warn( current );
}
}
+
+ if ( StringUtils.isNotEmpty( err.getOutput() ) && failOnWarnings )
+ {
+ throw new MavenReportException( "Project contains Javadoc Warnings" );
+ }
}
/**
@@ -5739,13 +5747,13 @@ public abstract class AbstractJavadocMojo
}
final String pluginId = "org.apache.maven.plugins:maven-compiler-plugin";
- JavadocVersion sourceVersion = javadocRuntimeVersion;
+ JavaVersion sourceVersion = javadocRuntimeVersion;
String sourceConfigured = getPluginParameter( project, pluginId, "source" );
if ( sourceConfigured != null )
{
try
{
- sourceVersion = JavadocVersion.parse( sourceConfigured );
+ sourceVersion = JavaVersion.parse( sourceConfigured );
}
catch ( NumberFormatException e )
{
@@ -5825,6 +5833,31 @@ public abstract class AbstractJavadocMojo
}
/**
+ * Follows all of the given links, and returns their last redirect locations. Ordering is kept.
+ * This is necessary because javadoc tool doesn't follow links, see JDK-8190312 (MJAVADOC-427, MJAVADOC-487)
+ *
+ * @param links Links to follow.
+ * @return Last redirect location of all the links.
+ */
+ private Set<String> followLinks( Set<String> links )
+ {
+ Set<String> redirectLinks = new LinkedHashSet<>( links.size() );
+ for ( String link : links )
+ {
+ try
+ {
+ redirectLinks.add( JavadocUtil.getRedirectUrl( new URI( link ).toURL(), settings ).toString() );
+ }
+ catch ( Exception e )
+ {
+ // only print in debug, it should have been logged already in warn/error because link isn't valid
+ getLog().debug( "Could not follow " + link + ". Reason: " + e.getMessage() );
+ }
+ }
+ return redirectLinks;
+ }
+
+ /**
* @param link not null
* @param detecting <code>true</code> if the link is generated by
* <code>detectLinks</code>, or <code>false</code> otherwise
=====================================
src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java
=====================================
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java
@@ -168,9 +168,9 @@ public class JavadocReport
/**
* {@inheritDoc}
*
- * <br/>
+ * <br>
* The logic is the following:
- * <table>
+ * <table summary="Can-generate-report Matrix">
* <tbody>
* <tr>
* <th> isAggregator </th>
=====================================
src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
=====================================
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -19,7 +19,6 @@ package org.apache.maven.plugins.javadoc;
* under the License.
*/
-import org.apache.commons.lang3.SystemUtils;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
@@ -29,6 +28,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.params.ClientPNames;
+import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
@@ -48,6 +48,7 @@ import org.apache.maven.shared.invoker.MavenInvocationException;
import org.apache.maven.shared.invoker.PrintStreamHandler;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.proxy.ProxyUtils;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
@@ -72,6 +73,7 @@ import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Modifier;
import java.net.SocketTimeoutException;
+import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
@@ -106,12 +108,11 @@ public class JavadocUtil
/** Error message when VM could not be started using invoker. */
protected static final String ERROR_INIT_VM =
"Error occurred during initialization of VM, try to reduce the Java heap size for the MAVEN_OPTS "
- + "environnement variable using -Xms:<size> and -Xmx:<size>.";
+ + "environnement variable using -Xms:<size> and -Xmx:<size>.";
/**
- * Method that removes the invalid directories in the specified directories.
- * <b>Note</b>: All elements in <code>dirs</code> could be an absolute or relative against the project's base
- * directory <code>String</code> path.
+ * Method that removes the invalid directories in the specified directories. <b>Note</b>: All elements in
+ * <code>dirs</code> could be an absolute or relative against the project's base directory <code>String</code> path.
*
* @param project the current Maven project not null
* @param dirs the collection of <code>String</code> directories path that will be validated.
@@ -143,8 +144,8 @@ public class JavadocUtil
}
/**
- * Method that removes the invalid files in the specified files.
- * <b>Note</b>: All elements in <code>files</code> should be an absolute <code>String</code> path.
+ * Method that removes the invalid files in the specified files. <b>Note</b>: All elements in <code>files</code>
+ * should be an absolute <code>String</code> path.
*
* @param files the list of <code>String</code> files paths that will be validated.
* @return a List of valid <code>File</code> objects.
@@ -159,13 +160,14 @@ public class JavadocUtil
pruned.add( f );
}
}
-
+
return pruned;
}
/**
- * Determine whether a file should be excluded from the provided list of paths, based on whether
- * it exists and is already present in the list.
+ * Determine whether a file should be excluded from the provided list of paths, based on whether it exists and is
+ * already present in the list.
+ *
* @param f The files.
* @param pruned The list of pruned files..
* @return true if the file could be pruned false otherwise.
@@ -180,16 +182,15 @@ public class JavadocUtil
return false;
}
}
-
+
return true;
}
/**
- * Method that gets all the source files to be excluded from the javadoc on the given
- * source paths.
+ * Method that gets all the source files to be excluded from the javadoc on the given source paths.
*
- * @param sourcePaths the path to the source files
- * @param subpackagesList list of subpackages to be included in the javadoc
+ * @param sourcePaths the path to the source files
+ * @param subpackagesList list of subpackages to be included in the javadoc
* @param excludedPackages the package names to be excluded in the javadoc
* @return a List of the source files to be excluded in the generated javadoc
*/
@@ -210,9 +211,8 @@ public class JavadocUtil
}
/**
- * Convenience method to wrap an argument value in single quotes (i.e. <code>'</code>). Intended for values
- * which may contain whitespaces.
- * <br/>
+ * Convenience method to wrap an argument value in single quotes (i.e. <code>'</code>). Intended for values which
+ * may contain whitespaces. <br>
* To prevent javadoc error, the line separator (i.e. <code>\n</code>) are skipped.
*
* @param value the argument value.
@@ -238,8 +238,8 @@ public class JavadocUtil
}
/**
- * Convenience method to format a path argument so that it is properly interpreted by the javadoc tool. Intended
- * for path values which may contain whitespaces.
+ * Convenience method to format a path argument so that it is properly interpreted by the javadoc tool. Intended for
+ * path values which may contain whitespaces.
*
* @param value the argument value.
* @return path argument with quote
@@ -275,8 +275,8 @@ public class JavadocUtil
}
/**
- * Convenience method that copy all <code>doc-files</code> directories from <code>javadocDir</code>
- * to the <code>outputDirectory</code>.
+ * Convenience method that copy all <code>doc-files</code> directories from <code>javadocDir</code> to the
+ * <code>outputDirectory</code>.
*
* @param outputDirectory the output directory
* @param javadocDir the javadoc directory
@@ -315,8 +315,8 @@ public class JavadocUtil
FileUtils.mkdir( docFileOutput.getAbsolutePath() );
FileUtils.copyDirectoryStructure( new File( javadocDir, docFile ), docFileOutput );
List<String> files =
- FileUtils.getFileAndDirectoryNames( docFileOutput, StringUtils.join( excludes.iterator(), "," ),
- null, true, true, true, true );
+ FileUtils.getFileAndDirectoryNames( docFileOutput, StringUtils.join( excludes.iterator(), "," ), null,
+ true, true, true, true );
for ( String filename : files )
{
File file = new File( filename );
@@ -334,11 +334,10 @@ public class JavadocUtil
}
/**
- * Method that gets the files or classes that would be included in the javadocs using the subpackages
- * parameter.
+ * Method that gets the files or classes that would be included in the javadocs using the subpackages parameter.
*
* @param sourceDirectory the directory where the source files are located
- * @param fileList the list of all files found in the sourceDirectory
+ * @param fileList the list of all files found in the sourceDirectory
* @param excludePackages package names to be excluded in the javadoc
* @return a StringBuilder that contains the appended file names of the files to be included in the javadoc
*/
@@ -409,10 +408,10 @@ public class JavadocUtil
}
/**
- * Method that gets the complete package names (including subpackages) of the packages that were defined
- * in the excludePackageNames parameter.
+ * Method that gets the complete package names (including subpackages) of the packages that were defined in the
+ * excludePackageNames parameter.
*
- * @param sourceDirectory the directory where the source files are located
+ * @param sourceDirectory the directory where the source files are located
* @param excludePackagenames package names to be excluded in the javadoc
* @return a List of the packagenames to be excluded
*/
@@ -465,10 +464,8 @@ public class JavadocUtil
* @param sourceFileIncludes files to include.
* @param sourceFileExcludes files to exclude.
*/
- protected static void addFilesFromSource( List<String> files, File sourceDirectory,
- List<String> sourceFileIncludes,
- List<String> sourceFileExcludes,
- String[] excludePackages )
+ protected static void addFilesFromSource( List<String> files, File sourceDirectory, List<String> sourceFileIncludes,
+ List<String> sourceFileExcludes, String[] excludePackages )
{
DirectoryScanner ds = new DirectoryScanner();
if ( sourceFileIncludes == null )
@@ -490,8 +487,7 @@ public class JavadocUtil
pathList[x] = new File( sourceDirectory, fileList[x] ).getAbsolutePath();
}
-
- if ( pathList.length != 0 )
+ if ( pathList.length != 0 )
{
List<String> tmpFiles = getIncludedFiles( sourceDirectory, pathList, excludePackages );
files.addAll( tmpFiles );
@@ -500,8 +496,9 @@ public class JavadocUtil
/**
* Call the Javadoc tool and parse its output to find its version, i.e.:
+ *
* <pre>
- * javadoc.exe(or .sh) -J-version
+ * javadoc.exe( or.sh ) - J - version
* </pre>
*
* @param javadocExe not null file
@@ -512,7 +509,7 @@ public class JavadocUtil
* @throws PatternSyntaxException if the output contains a syntax error in the regular-expression pattern.
* @see #extractJavadocVersion(String)
*/
- protected static JavadocVersion getJavadocVersion( File javadocExe )
+ protected static JavaVersion getJavadocVersion( File javadocExe )
throws IOException, CommandLineException, IllegalArgumentException
{
if ( ( javadocExe == null ) || ( !javadocExe.exists() ) || ( !javadocExe.isFile() ) )
@@ -525,8 +522,8 @@ public class JavadocUtil
cmd.setWorkingDirectory( javadocExe.getParentFile() );
cmd.createArg().setValue( "-J-version" );
- CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
- CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
+ CommandLineUtils.StringStreamConsumer out = new JavadocOutputStreamConsumer();
+ CommandLineUtils.StringStreamConsumer err = new JavadocOutputStreamConsumer();
int exitCode = CommandLineUtils.executeCommandLine( cmd, out, err );
@@ -540,55 +537,54 @@ public class JavadocUtil
if ( StringUtils.isNotEmpty( err.getOutput() ) )
{
- return JavadocVersion.parse( extractJavadocVersion( err.getOutput() ) );
+ return JavaVersion.parse( extractJavadocVersion( err.getOutput() ) );
}
else if ( StringUtils.isNotEmpty( out.getOutput() ) )
{
- return JavadocVersion.parse( extractJavadocVersion( out.getOutput() ) );
+ return JavaVersion.parse( extractJavadocVersion( out.getOutput() ) );
}
throw new IllegalArgumentException( "No output found from the command line 'javadoc -J-version'" );
}
/**
- * Parse the output for 'javadoc -J-version' and return the javadoc version recognized.
- * <br/>
+ * Parse the output for 'javadoc -J-version' and return the javadoc version recognized. <br>
* Here are some output for 'javadoc -J-version' depending the JDK used:
- * <table>
+ * <table summary="Output for 'javadoc -J-version' per JDK">
* <tr>
- * <th>JDK</th>
- * <th>Output for 'javadoc -J-version'</th>
+ * <th>JDK</th>
+ * <th>Output for 'javadoc -J-version'</th>
* </tr>
* <tr>
- * <td>Sun 1.4</td>
- * <td>java full version "1.4.2_12-b03"</td>
+ * <td>Sun 1.4</td>
+ * <td>java full version "1.4.2_12-b03"</td>
* </tr>
* <tr>
- * <td>Sun 1.5</td>
- * <td>java full version "1.5.0_07-164"</td>
+ * <td>Sun 1.5</td>
+ * <td>java full version "1.5.0_07-164"</td>
* </tr>
* <tr>
- * <td>IBM 1.4</td>
- * <td>javadoc full version "J2RE 1.4.2 IBM Windows 32 build cn1420-20040626"</td>
+ * <td>IBM 1.4</td>
+ * <td>javadoc full version "J2RE 1.4.2 IBM Windows 32 build cn1420-20040626"</td>
* </tr>
* <tr>
- * <td>IBM 1.5 (French JVM)</td>
- * <td>javadoc version complète de "J2RE 1.5.0 IBM Windows 32 build pwi32pdev-20070426a"</td>
+ * <td>IBM 1.5 (French JVM)</td>
+ * <td>javadoc version complète de "J2RE 1.5.0 IBM Windows 32 build pwi32pdev-20070426a"</td>
* </tr>
* <tr>
- * <td>FreeBSD 1.5</td>
- * <td>java full version "diablo-1.5.0-b01"</td>
+ * <td>FreeBSD 1.5</td>
+ * <td>java full version "diablo-1.5.0-b01"</td>
* </tr>
* <tr>
- * <td>BEA jrockit 1.5</td>
- * <td>java full version "1.5.0_11-b03"</td>
+ * <td>BEA jrockit 1.5</td>
+ * <td>java full version "1.5.0_11-b03"</td>
* </tr>
* </table>
*
* @param output for 'javadoc -J-version'
* @return the version of the javadoc for the output, only digits and dots
* @throws PatternSyntaxException if the output doesn't match with the output pattern
- * <tt>(?s).*?[^a-zA-Z]([0-9]+\\.?[0-9]*)(\\.([0-9]+))?.*</tt>.
+ * <tt>(?s).*?[^a-zA-Z]([0-9]+\\.?[0-9]*)(\\.([0-9]+))?.*</tt>.
* @throws IllegalArgumentException if the output is null
*/
protected static String extractJavadocVersion( String output )
@@ -612,32 +608,31 @@ public class JavadocUtil
}
/**
- * Parse a memory string which be used in the JVM arguments <code>-Xms</code> or <code>-Xmx</code>.
- * <br/>
+ * Parse a memory string which be used in the JVM arguments <code>-Xms</code> or <code>-Xmx</code>. <br>
* Here are some supported memory string depending the JDK used:
- * <table>
+ * <table summary="Memory argument support per JDK">
* <tr>
- * <th>JDK</th>
- * <th>Memory argument support for <code>-Xms</code> or <code>-Xmx</code></th>
+ * <th>JDK</th>
+ * <th>Memory argument support for <code>-Xms</code> or <code>-Xmx</code></th>
* </tr>
* <tr>
- * <td>SUN</td>
- * <td>1024k | 128m | 1g | 1t</td>
+ * <td>SUN</td>
+ * <td>1024k | 128m | 1g | 1t</td>
* </tr>
* <tr>
- * <td>IBM</td>
- * <td>1024k | 1024b | 128m | 128mb | 1g | 1gb</td>
+ * <td>IBM</td>
+ * <td>1024k | 1024b | 128m | 128mb | 1g | 1gb</td>
* </tr>
* <tr>
- * <td>BEA</td>
- * <td>1024k | 1024kb | 128m | 128mb | 1g | 1gb</td>
+ * <td>BEA</td>
+ * <td>1024k | 1024kb | 128m | 128mb | 1g | 1gb</td>
* </tr>
* </table>
*
* @param memory the memory to be parsed, not null.
- * @return the memory parsed with a supported unit. If no unit specified in the <code>memory</code> parameter,
- * the default unit is <code>m</code>. The units <code>g | gb</code> or <code>t | tb</code> will be converted
- * in <code>m</code>.
+ * @return the memory parsed with a supported unit. If no unit specified in the <code>memory</code> parameter, the
+ * default unit is <code>m</code>. The units <code>g | gb</code> or <code>t | tb</code> will be converted in
+ * <code>m</code>.
* @throws IllegalArgumentException if the <code>memory</code> parameter is null or doesn't match any pattern.
*/
protected static String parseJavadocMemory( String memory )
@@ -720,8 +715,8 @@ public class JavadocUtil
}
/**
- * For security reasons, if an active proxy is defined and needs an authentication by
- * username/password, hide the proxy password in the command line.
+ * For security reasons, if an active proxy is defined and needs an authentication by username/password, hide the
+ * proxy password in the command line.
*
* @param cmdLine a command line, not null
* @param settings the user settings
@@ -755,16 +750,15 @@ public class JavadocUtil
}
/**
- * Auto-detect the class names of the implementation of <code>com.sun.tools.doclets.Taglet</code> class from a
- * given jar file.
- * <br/>
+ * Auto-detect the class names of the implementation of <code>com.sun.tools.doclets.Taglet</code> class from a given
+ * jar file. <br>
* <b>Note</b>: <code>JAVA_HOME/lib/tools.jar</code> is a requirement to find
* <code>com.sun.tools.doclets.Taglet</code> class.
*
* @param jarFile not null
* @return the list of <code>com.sun.tools.doclets.Taglet</code> class names from a given jarFile.
- * @throws IOException if jarFile is invalid or not found, or if the <code>JAVA_HOME/lib/tools.jar</code>
- * is not found.
+ * @throws IOException if jarFile is invalid or not found, or if the <code>JAVA_HOME/lib/tools.jar</code> is not
+ * found.
* @throws ClassNotFoundException if any
* @throws NoClassDefFoundError if any
*/
@@ -788,8 +782,8 @@ public class JavadocUtil
List<String> tagletClasses = new ArrayList<>();
Class<?> tagletClass;
-
- try
+
+ try
{
tagletClass = cl.loadClass( "com.sun.tools.doclets.Taglet" );
}
@@ -797,7 +791,7 @@ public class JavadocUtil
{
tagletClass = cl.loadClass( "jdk.javadoc.doclet.Taglet" );
}
-
+
for ( String s : classes )
{
Class<?> c = cl.loadClass( s );
@@ -864,9 +858,8 @@ public class JavadocUtil
}
/**
- * Invoke Maven for the given project file with a list of goals and properties, the output will be in the
- * invokerlog file.
- * <br/>
+ * Invoke Maven for the given project file with a list of goals and properties, the output will be in the invokerlog
+ * file. <br>
* <b>Note</b>: the Maven Home should be defined in the <code>maven.home</code> Java system property or defined in
* <code>M2_HOME</code> system env variables.
*
@@ -904,9 +897,8 @@ public class JavadocUtil
String mavenHome = getMavenHome( log );
if ( StringUtils.isEmpty( mavenHome ) )
{
- String msg =
- "Could NOT invoke Maven because no Maven Home is defined. You need to have set the M2_HOME "
- + "system env variable or a maven.home Java system properties.";
+ String msg = "Could NOT invoke Maven because no Maven Home is defined. You need to have set the M2_HOME "
+ + "system env variable or a maven.home Java system properties.";
if ( log != null )
{
log.error( msg );
@@ -956,9 +948,8 @@ public class JavadocUtil
String invokerLogContent = readFile( invokerLog, "UTF-8" );
// see DefaultMaven
- if ( invokerLogContent != null
- && ( !invokerLogContent.contains( "Scanning for projects..." )
- || invokerLogContent.contains( OutOfMemoryError.class.getName() ) ) )
+ if ( invokerLogContent != null && ( !invokerLogContent.contains( "Scanning for projects..." )
+ || invokerLogContent.contains( OutOfMemoryError.class.getName() ) ) )
{
if ( log != null )
{
@@ -978,9 +969,8 @@ public class JavadocUtil
String invokerLogContent = readFile( invokerLog, "UTF-8" );
// see DefaultMaven
- if ( invokerLogContent != null
- && ( !invokerLogContent.contains( "Scanning for projects..." )
- || invokerLogContent.contains( OutOfMemoryError.class.getName() ) ) )
+ if ( invokerLogContent != null && ( !invokerLogContent.contains( "Scanning for projects..." )
+ || invokerLogContent.contains( OutOfMemoryError.class.getName() ) ) )
{
throw new MavenInvocationException( ERROR_INIT_VM );
}
@@ -1012,8 +1002,8 @@ public class JavadocUtil
}
/**
- * Split the given path with colon and semi-colon, to support Solaris and Windows path.
- * Examples:
+ * Split the given path with colon and semi-colon, to support Solaris and Windows path. Examples:
+ *
* <pre>
* splitPath( "/home:/tmp" ) = ["/home", "/tmp"]
* splitPath( "/home;/tmp" ) = ["/home", "/tmp"]
@@ -1021,8 +1011,8 @@ public class JavadocUtil
* splitPath( "C:/home;C:/tmp" ) = ["C:/home", "C:/tmp"]
* </pre>
*
- * @param path which can contain multiple paths separated with a colon (<code>:</code>) or a
- * semi-colon (<code>;</code>), platform independent. Could be null.
+ * @param path which can contain multiple paths separated with a colon (<code>:</code>) or a semi-colon
+ * (<code>;</code>), platform independent. Could be null.
* @return the path splitted by colon or semi-colon or <code>null</code> if path was <code>null</code>.
* @since 2.6.1
*/
@@ -1044,17 +1034,17 @@ public class JavadocUtil
}
/**
- * Unify the given path with the current System path separator, to be platform independent.
- * Examples:
+ * Unify the given path with the current System path separator, to be platform independent. Examples:
+ *
* <pre>
* unifyPathSeparator( "/home:/tmp" ) = "/home:/tmp" (Solaris box)
* unifyPathSeparator( "/home:/tmp" ) = "/home;/tmp" (Windows box)
* </pre>
*
- * @param path which can contain multiple paths by separating them with a colon (<code>:</code>) or a
- * semi-colon (<code>;</code>), platform independent. Could be null.
+ * @param path which can contain multiple paths by separating them with a colon (<code>:</code>) or a semi-colon
+ * (<code>;</code>), platform independent. Could be null.
* @return the same path but separated with the current System path separator or <code>null</code> if path was
- * <code>null</code>.
+ * <code>null</code>.
* @since 2.6.1
* @see #splitPath(String)
* @see File#pathSeparator
@@ -1093,8 +1083,8 @@ public class JavadocUtil
{
jarStream = new JarInputStream( new FileInputStream( jarFile ) );
- for ( JarEntry jarEntry = jarStream.getNextJarEntry(); jarEntry != null;
- jarEntry = jarStream.getNextJarEntry() )
+ for ( JarEntry jarEntry = jarStream.getNextJarEntry(); jarEntry != null; jarEntry =
+ jarStream.getNextJarEntry() )
{
if ( jarEntry.getName().toLowerCase( Locale.ENGLISH ).endsWith( ".class" ) )
{
@@ -1146,7 +1136,7 @@ public class JavadocUtil
{
if ( !invokerLog.exists() )
{
- //noinspection ResultOfMethodCallIgnored
+ // noinspection ResultOfMethodCallIgnored
invokerLog.getParentFile().mkdirs();
}
os = new FileOutputStream( invokerLog );
@@ -1209,8 +1199,8 @@ public class JavadocUtil
/**
* @param log a logger could be null
- * @return the Maven home defined in the <code>maven.home</code> system property or defined
- * in <code>M2_HOME</code> system env variables or null if never set.
+ * @return the Maven home defined in the <code>maven.home</code> system property or defined in <code>M2_HOME</code>
+ * system env variables or null if never set.
* @since 2.6
*/
private static String getMavenHome( Log log )
@@ -1236,9 +1226,8 @@ public class JavadocUtil
{
if ( log != null && log.isErrorEnabled() )
{
- log
- .error( "Cannot find Maven application directory. Either specify \'maven.home\' system property, or "
- + "M2_HOME environment variable." );
+ log.error( "Cannot find Maven application directory. Either specify \'maven.home\' system property, or "
+ + "M2_HOME environment variable." );
}
}
@@ -1270,44 +1259,45 @@ public class JavadocUtil
/**
* @param log a logger could be null
- * @return the <code>JAVA_HOME</code> from System.getProperty( "java.home" )
- * By default, <code>System.getProperty( "java.home" ) = JRE_HOME</code> and <code>JRE_HOME</code>
- * should be in the <code>JDK_HOME</code>
+ * @return the <code>JAVA_HOME</code> from System.getProperty( "java.home" ) By default,
+ * <code>System.getProperty( "java.home" ) = JRE_HOME</code> and <code>JRE_HOME</code> should be in the
+ * <code>JDK_HOME</code>
* @since 2.6
*/
private static File getJavaHome( Log log )
{
File javaHome = null;
+ String javaHomeValue = null;
+ try
+ {
+ javaHomeValue = CommandLineUtils.getSystemEnvVars().getProperty( "JAVA_HOME" );
+ }
+ catch ( IOException e )
+ {
+ if ( log != null && log.isDebugEnabled() )
+ {
+ log.debug( "IOException: " + e.getMessage() );
+ }
+ }
+
// if maven.home is set, we can assume JAVA_HOME must be used for testing
-
- if ( System.getProperty( "maven.home" ) == null )
+ if ( System.getProperty( "maven.home" ) == null || javaHomeValue == null )
{
// JEP220 (Java9) restructured the JRE/JDK runtime image
- if ( ( SystemUtils.IS_OS_MAC_OSX
- || JavadocVersion.parse( SystemUtils.JAVA_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) >= 0 ) )
+ if ( SystemUtils.IS_OS_MAC_OSX || JavaVersion.JAVA_VERSION.isAtLeast( "9" ) )
{
javaHome = SystemUtils.getJavaHome();
}
else
{
javaHome = new File( SystemUtils.getJavaHome(), ".." );
- }
+ }
}
if ( javaHome == null || !javaHome.exists() )
{
- try
- {
- javaHome = new File( CommandLineUtils.getSystemEnvVars().getProperty( "JAVA_HOME" ) );
- }
- catch ( IOException e )
- {
- if ( log != null && log.isDebugEnabled() )
- {
- log.debug( "IOException: " + e.getMessage() );
- }
- }
+ javaHome = new File( javaHomeValue );
}
if ( javaHome == null || !javaHome.exists() )
@@ -1346,14 +1336,11 @@ public class JavadocUtil
}
/**
- * A Path tokenizer takes a path and returns the components that make up
- * that path.
- *
- * The path can use path separators of either ':' or ';' and file separators
- * of either '/' or '\'.
+ * A Path tokenizer takes a path and returns the components that make up that path. The path can use path separators
+ * of either ':' or ';' and file separators of either '/' or '\'.
*
- * @version revision 439418 taken on 2009-09-12 from Ant Project
- * (see http://svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/tools/ant/PathTokenizer.java)
+ * @version revision 439418 taken on 2009-09-12 from Ant Project (see
+ * http://svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/tools/ant/PathTokenizer.java)
*/
private static class PathTokenizer
{
@@ -1363,21 +1350,18 @@ public class JavadocUtil
private StringTokenizer tokenizer;
/**
- * A String which stores any path components which have been read ahead
- * due to DOS filesystem compensation.
+ * A String which stores any path components which have been read ahead due to DOS filesystem compensation.
*/
private String lookahead = null;
/**
- * A boolean that determines if we are running on Novell NetWare, which
- * exhibits slightly different path name characteristics (multi-character
- * volume / drive names)
+ * A boolean that determines if we are running on Novell NetWare, which exhibits slightly different path name
+ * characteristics (multi-character volume / drive names)
*/
private boolean onNetWare = Os.isFamily( "netware" );
/**
- * Flag to indicate whether or not we are running on a platform with a
- * DOS style filesystem
+ * Flag to indicate whether or not we are running on a platform with a DOS style filesystem
*/
private boolean dosStyleFilesystem;
@@ -1386,7 +1370,7 @@ public class JavadocUtil
*
* @param path The path to tokenize. Must not be <code>null</code>.
*/
- public PathTokenizer( String path )
+ PathTokenizer( String path )
{
if ( onNetWare )
{
@@ -1404,12 +1388,11 @@ public class JavadocUtil
}
/**
- * Tests if there are more path elements available from this tokenizer's
- * path. If this method returns <code>true</code>, then a subsequent call
- * to nextToken will successfully return a token.
+ * Tests if there are more path elements available from this tokenizer's path. If this method returns
+ * <code>true</code>, then a subsequent call to nextToken will successfully return a token.
*
- * @return <code>true</code> if and only if there is at least one token
- * in the string after the current position; <code>false</code> otherwise.
+ * @return <code>true</code> if and only if there is at least one token in the string after the current
+ * position; <code>false</code> otherwise.
*/
public boolean hasMoreTokens()
{
@@ -1421,9 +1404,7 @@ public class JavadocUtil
* Returns the next path element from this tokenizer.
*
* @return the next path element from this tokenizer.
- *
- * @exception NoSuchElementException if there are no more elements in this
- * tokenizer's path.
+ * @exception NoSuchElementException if there are no more elements in this tokenizer's path.
*/
public String nextToken()
throws NoSuchElementException
@@ -1510,19 +1491,38 @@ public class JavadocUtil
return token;
}
}
-
+
+ /**
+ * Ignores line like 'Picked up JAVA_TOOL_OPTIONS: ...' as can happen on CI servers.
+ *
+ * @author Robert Scholte
+ * @since 3.0.1
+ */
+ private static class JavadocOutputStreamConsumer
+ extends CommandLineUtils.StringStreamConsumer
+ {
+ @Override
+ public void consumeLine( String line )
+ {
+ if ( !line.startsWith( "Picked up " ) )
+ {
+ super.consumeLine( line );
+ }
+ }
+ }
+
static List<String> toList( String src )
{
return toList( src, null, null );
}
-
+
static List<String> toList( String src, String elementPrefix, String elementSuffix )
{
if ( StringUtils.isEmpty( src ) )
{
return null;
}
-
+
List<String> result = new ArrayList<>();
StringTokenizer st = new StringTokenizer( src, "[,:;]" );
@@ -1534,46 +1534,46 @@ public class JavadocUtil
{
sb.append( elementPrefix );
}
-
+
sb.append( st.nextToken() );
-
+
if ( StringUtils.isNotEmpty( elementSuffix ) )
{
sb.append( elementSuffix );
}
-
+
result.add( sb.toString() );
}
-
+
return result;
}
-
+
static <T> List<T> toList( T[] multiple )
{
return toList( null, multiple );
}
-
+
static <T> List<T> toList( T single, T[] multiple )
{
if ( single == null && ( multiple == null || multiple.length < 1 ) )
{
return null;
}
-
+
List<T> result = new ArrayList<>();
if ( single != null )
{
result.add( single );
}
-
+
if ( multiple != null && multiple.length > 0 )
{
result.addAll( Arrays.asList( multiple ) );
}
-
+
return result;
}
-
+
// TODO: move to plexus-utils or use something appropriate from there
public static String toRelative( File basedir, String absolutePath )
{
@@ -1601,17 +1601,21 @@ public class JavadocUtil
return relative;
}
-
+
/**
* Convenience method to determine that a collection is not empty or null.
+ * @param collection the collection to verify
+ * @return {@code true} if not {@code null} and not empty, otherwise {@code false}
*/
public static boolean isNotEmpty( final Collection<?> collection )
{
return collection != null && !collection.isEmpty();
}
-
+
/**
* Convenience method to determine that a collection is empty or null.
+ * @param collection the collection to verify
+ * @return {@code true} if {@code null} or empty, otherwise {@code false}
*/
public static boolean isEmpty( final Collection<?> collection )
{
@@ -1619,20 +1623,59 @@ public class JavadocUtil
}
/**
+ * Execute an Http request at the given URL, follows redirects, and returns the last redirect locations. For URLs
+ * that aren't http/https, this does nothing and simply returns the given URL unchanged.
+ *
+ * @param url URL.
+ * @param settings Maven settings.
+ * @return Last redirect location.
+ * @throws IOException if there was an error during the Http request.
+ */
+ protected static URL getRedirectUrl( URL url, Settings settings )
+ throws IOException
+ {
+ String protocol = url.getProtocol();
+ if ( !"http".equals( protocol ) && !"https".equals( protocol ) )
+ {
+ return url;
+ }
+ HttpClient httpClient = null;
+ try
+ {
+ httpClient = createHttpClient( settings, url );
+ HttpClientContext httpContext = HttpClientContext.create();
+ HttpGet httpMethod = new HttpGet( url.toString() );
+ HttpResponse response = httpClient.execute( httpMethod, httpContext );
+ int status = response.getStatusLine().getStatusCode();
+ if ( status != HttpStatus.SC_OK )
+ {
+ throw new FileNotFoundException( "Unexpected HTTP status code " + status + " getting resource "
+ + url.toExternalForm() + "." );
+ }
+
+ List<URI> redirects = httpContext.getRedirectLocations();
+ return redirects.isEmpty() ? url : redirects.get( redirects.size() - 1 ).toURL();
+ }
+ finally
+ {
+ if ( httpClient != null )
+ {
+ httpClient.getConnectionManager().shutdown();
+ }
+ }
+ }
+
+ /**
* Validates an <code>URL</code> to point to a valid <code>package-list</code> resource.
*
* @param url The URL to validate.
* @param settings The user settings used to configure the connection to the URL or {@code null}.
* @param validateContent <code>true</code> to validate the content of the <code>package-list</code> resource;
- * <code>false</code> to only check the existence of the <code>package-list</code> resource.
- *
+ * <code>false</code> to only check the existence of the <code>package-list</code> resource.
* @return <code>true</code> if <code>url</code> points to a valid <code>package-list</code> resource;
- * <code>false</code> else.
- *
+ * <code>false</code> else.
* @throws IOException if reading the resource fails.
- *
* @see #createHttpClient(org.apache.maven.settings.Settings, java.net.URL)
- *
* @since 2.8
*/
protected static boolean isValidPackageList( URL url, Settings settings, boolean validateContent )
@@ -1674,8 +1717,8 @@ public class JavadocUtil
int status = response.getStatusLine().getStatusCode();
if ( status != HttpStatus.SC_OK )
{
- throw new FileNotFoundException(
- "Unexpected HTTP status code " + status + " getting resource " + url.toExternalForm() + "." );
+ throw new FileNotFoundException( "Unexpected HTTP status code " + status + " getting resource "
+ + url.toExternalForm() + "." );
}
// Intentionally using the platform default encoding here since this is what Javadoc uses internally.
@@ -1758,9 +1801,7 @@ public class JavadocUtil
*
* @param settings The settings to use for setting up the client or {@code null}.
* @param url The {@code URL} to use for setting up the client or {@code null}.
- *
* @return A new {@code HttpClient} instance.
- *
* @see #DEFAULT_TIMEOUT
* @since 2.8
*/
@@ -1783,7 +1824,7 @@ public class JavadocUtil
proxyInfo.setNonProxyHosts( activeProxy.getNonProxyHosts() );
if ( StringUtils.isNotEmpty( activeProxy.getHost() )
- && ( url == null || !ProxyUtils.validateNonProxyHosts( proxyInfo, url.getHost() ) ) )
+ && ( url == null || !ProxyUtils.validateNonProxyHosts( proxyInfo, url.getHost() ) ) )
{
HttpHost proxy = new HttpHost( activeProxy.getHost(), activeProxy.getPort() );
httpClient.getParams().setParameter( ConnRoutePNames.DEFAULT_PROXY, proxy );
=====================================
src/main/java/org/apache/maven/plugins/javadoc/JavadocVersion.java
=====================================
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocVersion.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocVersion.java
@@ -30,7 +30,9 @@ import org.codehaus.plexus.util.StringUtils;
*
* @author Robert Scholte
* @since 3.0.0
+ * @deprecated Use {@link org.codehaus.plexus.languages.java.version.JavaVersion} instead
*/
+ at Deprecated
public class JavadocVersion implements Comparable<JavadocVersion>
{
private String rawVersion;
=====================================
src/main/java/org/apache/maven/plugins/javadoc/SystemUtils.java
=====================================
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/javadoc/SystemUtils.java
@@ -0,0 +1,181 @@
+package org.apache.maven.plugins.javadoc;
+
+/*
+ * 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.File;
+
+/**
+ * Contains several OS-specific methods from Commons-Lang3's SystemUtils. We don't want to use that class because it
+ * uses enums for Java versions, which implies that with every new Java version a new commons-lang3 is required.
+ *
+ * @author Robert Scholte
+ * @since 3.0.1
+ */
+class SystemUtils
+{
+ /**
+ * <p>
+ * The {@code os.name} System Property. Operating system name.
+ * </p>
+ * <p>
+ * Defaults to {@code null} if the runtime does not have security access to read this property or the property does
+ * not exist.
+ * </p>
+ * <p>
+ * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or
+ * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of
+ * sync with that System property.
+ * </p>
+ *
+ * @since Java 1.1
+ */
+ public static final String OS_NAME = getSystemProperty( "os.name" );
+
+ /**
+ * The prefix String for all Windows OS.
+ */
+ private static final String OS_NAME_WINDOWS_PREFIX = "Windows";
+
+ /**
+ * <p>
+ * Is {@code true} if this is AIX.
+ * </p>
+ * <p>
+ * The field will return {@code false} if {@code OS_NAME} is {@code null}.
+ * </p>
+ */
+ public static final boolean IS_OS_AIX = getOSMatchesName( "AIX" );
+
+ /**
+ * <p>
+ * Is {@code true} if this is Mac.
+ * </p>
+ * <p>
+ * The field will return {@code false} if {@code OS_NAME} is {@code null}.
+ * </p>
+ */
+ public static final boolean IS_OS_MAC_OSX = getOSMatchesName( "Mac OS X" );
+
+ /**
+ * <p>
+ * Is {@code true} if this is Windows.
+ * </p>
+ * <p>
+ * The field will return {@code false} if {@code OS_NAME} is {@code null}.
+ * </p>
+ */
+ public static final boolean IS_OS_WINDOWS = getOSMatchesName( OS_NAME_WINDOWS_PREFIX );
+
+ /**
+ * The System property key for the Java home directory.
+ */
+ private static final String JAVA_HOME_KEY = "java.home";
+
+ /**
+ * <p>
+ * The {@code line.separator} System Property. Line separator (<code>"\n"</code> on UNIX).
+ * </p>
+ * <p>
+ * Defaults to {@code null} if the runtime does not have security access to read this property or the property does
+ * not exist.
+ * </p>
+ * <p>
+ * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or
+ * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of
+ * sync with that System property.
+ * </p>
+ *
+ * @since Java 1.1
+ */
+ public static final String LINE_SEPARATOR = getSystemProperty( "line.separator" );
+
+ /**
+ * Decides if the operating system matches.
+ *
+ * @param osNamePrefix the prefix for the os name
+ * @return true if matches, or false if not or can't determine
+ */
+ private static boolean getOSMatchesName( final String osNamePrefix )
+ {
+ return isOSNameMatch( OS_NAME, osNamePrefix );
+ }
+
+ /**
+ * Decides if the operating system matches.
+ * <p>
+ * This method is package private instead of private to support unit test invocation.
+ * </p>
+ *
+ * @param osName the actual OS name
+ * @param osNamePrefix the prefix for the expected OS name
+ * @return true if matches, or false if not or can't determine
+ */
+ static boolean isOSNameMatch( final String osName, final String osNamePrefix )
+ {
+ if ( osName == null )
+ {
+ return false;
+ }
+ return osName.startsWith( osNamePrefix );
+ }
+
+ /**
+ * <p>
+ * Gets the Java home directory as a {@code File}.
+ * </p>
+ *
+ * @return a directory
+ * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow
+ * access to the specified system property.
+ * @see System#getProperty(String)
+ * @since 2.1
+ */
+ public static File getJavaHome()
+ {
+ return new File( System.getProperty( JAVA_HOME_KEY ) );
+ }
+
+ /**
+ * <p>
+ * Gets a System property, defaulting to {@code null} if the property cannot be read.
+ * </p>
+ * <p>
+ * If a {@code SecurityException} is caught, the return value is {@code null} and a message is written to
+ * {@code System.err}.
+ * </p>
+ *
+ * @param property the system property name
+ * @return the system property value or {@code null} if a security problem occurs
+ */
+ private static String getSystemProperty( final String property )
+ {
+ try
+ {
+ return System.getProperty( property );
+ }
+ catch ( final SecurityException ex )
+ {
+ // we are not allowed to look at this property
+ System.err.println( "Caught a SecurityException reading the system property '" + property
+ + "'; the SystemUtils property value will default to null." );
+ return null;
+ }
+ }
+}
=====================================
src/main/java/org/apache/maven/plugins/javadoc/resolver/SourceResolverConfig.java
=====================================
--- a/src/main/java/org/apache/maven/plugins/javadoc/resolver/SourceResolverConfig.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/resolver/SourceResolverConfig.java
@@ -47,7 +47,7 @@ public class SourceResolverConfig
/**
* @param project {@link MavenProject}
- * @param buoildingRequest {@link ProjectBuildingRequest}
+ * @param buildingRequest {@link ProjectBuildingRequest}
* @param outputBasedir The output base directory.
*/
public SourceResolverConfig( final MavenProject project, final ProjectBuildingRequest buildingRequest,
@@ -59,7 +59,7 @@ public class SourceResolverConfig
}
/**
- * @param filter {@link ArtifactFilter}
+ * @param filter {@link AndFilter}
* @return {@link SourceResolverConfig}
*/
public SourceResolverConfig withFilter( final AndFilter filter )
@@ -131,7 +131,7 @@ public class SourceResolverConfig
}
/**
- * @return {@link TransformableFilter}
+ * @return {@link AndFilter}
*/
public AndFilter filter()
{
=====================================
src/main/mdo/javadocOptions.mdo
=====================================
--- a/src/main/mdo/javadocOptions.mdo
+++ b/src/main/mdo/javadocOptions.mdo
@@ -19,9 +19,9 @@ specific language governing permissions and limitations
under the License.
-->
-<model xmlns="http://modello.codehaus.org/MODELLO/1.1.0"
+<model xmlns="https://codehaus-plexus.github.io/MODELLO/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://modello.codehaus.org/MODELLO/1.1.0 http://modello.codehaus.org/xsd/modello-1.1.0.xsd"
+ xsi:schemaLocation="https://codehaus-plexus.github.io/MODELLO/1.1.0 https://codehaus-plexus.github.io/modello/xsd/modello-1.1.0.xsd"
xsd.namespace="http://http://maven.apache.org/plugins/maven-javadoc-plugin/maven-javadoc-options/${version}"
xsd.targetNamespace="http://maven.apache.org/plugins/maven-javadoc-plugin/xsd/maven-javadoc-options-${version}.xsd">
<id>javadocoptions</id>
=====================================
src/site/xdoc/download.xml.vm
=====================================
--- a/src/site/xdoc/download.xml.vm
+++ b/src/site/xdoc/download.xml.vm
@@ -108,7 +108,7 @@ under the License.
<tr>
<td>${project.name} ${project.version} (Source zip)</td>
<td><a href="[preferred]maven/plugins/${project.artifactId}-${project.version}-source-release.zip">maven/plugins/${project.artifactId}-${project.version}-source-release.zip</a></td>
- <td><a href="http://www.apache.org/dist/maven/plugins/${project.artifactId}-${project.version}-source-release.zip.md5">maven/plugins/${project.artifactId}-${project.version}-source-release.zip.md5</a></td>
+ <td><a href="http://www.apache.org/dist/maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha1">maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha1</a></td>
<td><a href="http://www.apache.org/dist/maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc">maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc</a></td>
</tr>
</tbody>
=====================================
src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
=====================================
--- a/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
@@ -28,12 +28,12 @@ import java.util.Arrays;
import java.util.List;
import java.util.Properties;
-import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.plugins.javadoc.AbstractFixJavadocMojo.JavaEntityTags;
import org.apache.maven.shared.invoker.MavenInvocationException;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
@@ -150,7 +150,7 @@ public class FixJavadocMojoTest
{
// Should be an assumption, but not supported by TestCase
// Java 5 not supported by Java9 anymore
- if ( JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) >= 0 )
+ if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "9" ) )
{
return;
}
@@ -464,9 +464,6 @@ public class FixJavadocMojoTest
assertTrue( withoutEmptyJavadocLines.endsWith( "any" ) );
}
- /**
- * @throws Throwable if any
- */
public void testJavadocCommentJdk5()
throws Exception
{
@@ -649,11 +646,9 @@ public class FixJavadocMojoTest
invokerDir.mkdirs();
File invokerLogFile = FileUtils.createTempFile( "FixJavadocMojoTest", ".txt", invokerDir );
- JavadocVersion JAVA_9 = JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION );
-
Properties properties = new Properties();
- if( JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION ).compareTo( JAVA_9 ) >= 0 )
+ if( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "9" ) )
{
properties.put( "maven.compiler.source", "1.6" );
properties.put( "maven.compiler.target", "1.6" );
=====================================
src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java
=====================================
--- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java
@@ -33,10 +33,8 @@ import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.apache.maven.plugins.javadoc.AbstractJavadocMojo;
-import org.apache.maven.plugins.javadoc.JavadocJar;
-import org.apache.maven.plugins.javadoc.JavadocVersion;
import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
import org.codehaus.plexus.util.FileUtils;
/**
@@ -96,12 +94,12 @@ public class JavadocJarTest
}
assertTrue( set.contains( "stylesheet.css" ) );
- JavadocVersion javadocVersion = (JavadocVersion) getVariableValueFromObject( mojo, "javadocRuntimeVersion" );
- if ( javadocVersion.compareTo( JavadocVersion.parse( "1.7" ) ) < 0 )
+ JavaVersion javadocVersion = (JavaVersion) getVariableValueFromObject( mojo, "javadocRuntimeVersion" );
+ if ( javadocVersion.isBefore( "1.7" ) )
{
assertTrue( set.contains( "resources/inherit.gif" ) );
}
- else if ( javadocVersion.compareTo( JavadocVersion.parse( "1.8" ) ) < 0 )
+ else if ( javadocVersion.isBefore( "1.8" ) )
{
assertTrue( set.contains( "resources/background.gif" ) /* JDK7 */);
}
=====================================
src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
=====================================
--- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
@@ -27,11 +27,12 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
+import java.net.HttpURLConnection;
+import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.LegacySupport;
@@ -45,6 +46,7 @@ import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.repository.internal.MavenRepositorySystemSession;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Settings;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
@@ -228,7 +230,15 @@ public class JavadocReportTest
File generatedFile = new File( apidocs, "def/configuration/App.html" );
assertTrue( generatedFile.exists() );
- assertTrue( FileUtils.fileRead( generatedFile, "UTF-8" ).contains( "/docs/api/java/lang/Object.html" ) );
+
+ // only test when URL can be reached
+ String url = JavadocReport.DEFAULT_JAVA_API_LINKS.getProperty( "api_9" );
+ HttpURLConnection connection = (HttpURLConnection) new URL( url ).openConnection();
+ connection.setRequestMethod( "HEAD" );
+ if ( connection.getResponseCode() == 200 )
+ {
+ assertTrue( FileUtils.fileRead( generatedFile, "UTF-8" ).contains( "/docs/api/java/lang/Object.html" ) );
+ }
assertTrue( new File( apidocs, "def/configuration/AppSample.html" ).exists() );
assertTrue( new File( apidocs, "def/configuration/package-frame.html" ).exists() );
@@ -305,7 +315,7 @@ public class JavadocReportTest
{
// Should be an assumption, but not supported by TestCase
// Seems like a bug in Javadoc 9
- if ( JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) == 0 )
+ if ( JavaVersion.JAVA_SPECIFICATION_VERSION.compareTo( JavaVersion.parse( "9" ) ) == 0 )
{
return;
}
@@ -568,7 +578,7 @@ public class JavadocReportTest
{
// Should be an assumption, but not supported by TestCase
// Java 5 not supported by Java9 anymore
- if ( JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) >= 0 )
+ if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "9" ) )
{
return;
}
@@ -650,11 +660,12 @@ public class JavadocReportTest
content = readFile( app );
assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\">" ) );
- JavadocVersion javadocVersion = (JavadocVersion) getVariableValueFromObject( mojo, "javadocRuntimeVersion" );
- if( javadocVersion.compareTo( JavadocVersion.parse( "1.8" ) ) >= 0 && javadocVersion.compareTo( JavadocVersion.parse( "10" ) ) < 0)
+ JavaVersion javadocVersion = (JavaVersion) getVariableValueFromObject( mojo, "javadocRuntimeVersion" );
+ if( javadocVersion.isAtLeast( "1.8" ) && javadocVersion.isBefore( "10" ) )
{
// https://bugs.openjdk.java.net/browse/JDK-8032205
- assertTrue( "This bug appeared in JDK8 and was planned to be fixed in JDK9, see JDK-8032205",
+ assertTrue( "Javadoc runtime version: " + javadocVersion
+ + "\nThis bug appeared in JDK8 and was planned to be fixed in JDK9, see JDK-8032205",
new File( apidocs, "resources/test/doc-files/maven-feather.png" ).exists() );
}
else
=====================================
src/test/java/org/apache/maven/plugins/javadoc/JavadocUtilTest.java
=====================================
--- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocUtilTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocUtilTest.java
@@ -22,7 +22,9 @@ package org.apache.maven.plugins.javadoc;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.SocketTimeoutException;
+import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
@@ -32,6 +34,10 @@ import java.util.Map;
import java.util.Set;
import java.util.regex.PatternSyntaxException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.maven.plugins.javadoc.JavadocUtil;
import org.apache.maven.plugins.javadoc.ProxyServer.AuthAsyncProxyServlet;
@@ -39,6 +45,10 @@ import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.mortbay.jetty.handler.MovedContextHandler;
+import org.mortbay.util.ByteArrayISO8859Writer;
/**
* @author <a href="mailto:vincent.siveton at gmail.com">Vincent Siveton</a>
@@ -507,6 +517,65 @@ public class JavadocUtilTest
}
}
+ public void testGetRedirectUrlNotHttp()
+ throws Exception
+ {
+ URL url = new URI( "ftp://some.where" ).toURL();
+ assertEquals( url.toString(), JavadocUtil.getRedirectUrl( url, new Settings() ).toString() );
+
+ url = new URI( "file://some/where" ).toURL();
+ assertEquals( url.toString(), JavadocUtil.getRedirectUrl( url, new Settings() ).toString() );
+ }
+
+ /**
+ * Tests a redirect from localhost:port1 to localhost:port2
+ */
+ public void testGetRedirectUrl()
+ throws Exception
+ {
+ Server server = null, redirectServer = null;
+ try
+ {
+ redirectServer = new Server( 0 );
+ redirectServer.addHandler( new AbstractHandler()
+ {
+ @Override
+ public void handle( String target, HttpServletRequest request, HttpServletResponse response,
+ int dispatch )
+ throws IOException, ServletException
+ {
+ response.setStatus( HttpServletResponse.SC_OK );
+ ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer( 100 );
+ writer.write( "<html>Hello world</html>" );
+ writer.flush();
+ response.setContentLength( writer.size() );
+ OutputStream out = response.getOutputStream();
+ writer.writeTo( out );
+ out.close();
+ writer.close();
+ }
+ } );
+ redirectServer.start();
+
+ server = new Server( 0 );
+ MovedContextHandler handler = new MovedContextHandler();
+ int redirectPort = redirectServer.getConnectors()[0].getLocalPort();
+ handler.setNewContextURL( "http://localhost:" + redirectPort );
+ server.addHandler( handler );
+ server.start();
+
+ URL url = new URI( "http://localhost:" + server.getConnectors()[0].getLocalPort() ).toURL();
+ URL redirectUrl = JavadocUtil.getRedirectUrl( url, new Settings() );
+
+ assertTrue( redirectUrl.toString().startsWith( "http://localhost:" + redirectPort ) );
+ }
+ finally
+ {
+ stopSilently( server );
+ stopSilently( redirectServer );
+ }
+ }
+
/**
* Method to test copyJavadocResources()
*
@@ -626,4 +695,19 @@ public class JavadocUtilTest
assertEquals( path1 + ps + path2 + ps + path1 + ps + path2, JavadocUtil.unifyPathSeparator( path1 + ";"
+ path2 + ":" + path1 + ":" + path2 ) );
}
+
+ private void stopSilently( Server server )
+ {
+ try
+ {
+ if ( server != null )
+ {
+ server.stop();
+ }
+ }
+ catch ( Exception e )
+ {
+ // ignored
+ }
+ }
}
=====================================
src/test/resources/unit/docfiles-with-java-test/src/main/test/App.java
=====================================
--- a/src/test/resources/unit/docfiles-with-java-test/src/main/test/App.java
+++ b/src/test/resources/unit/docfiles-with-java-test/src/main/test/App.java
@@ -21,7 +21,7 @@ package test;
/**
* @author <a href="mailto:vincent.siveton at gmail.com">Vincent Siveton</a>
- * @version $Id: App.java 805778 2009-08-19 12:40:14Z vsiveton $
+ * @version $Id$
*/
public class App
{
=====================================
src/test/resources/unit/docfiles-with-java-test/src/main/test/doc-files/App.java
=====================================
--- a/src/test/resources/unit/docfiles-with-java-test/src/main/test/doc-files/App.java
+++ b/src/test/resources/unit/docfiles-with-java-test/src/main/test/doc-files/App.java
@@ -21,7 +21,7 @@ package test;
/**
* @author <a href="mailto:vincent.siveton at gmail.com">Vincent Siveton</a>
- * @version $Id: App.java 805778 2009-08-19 12:40:14Z vsiveton $
+ * @version $Id$
*/
public class App
{
View it on GitLab: https://salsa.debian.org/java-team/maven-javadoc-plugin/commit/0e82ba40b47be41dd21ed7d2bda373976f5a1f22
--
View it on GitLab: https://salsa.debian.org/java-team/maven-javadoc-plugin/commit/0e82ba40b47be41dd21ed7d2bda373976f5a1f22
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20180730/cba42645/attachment.html>
More information about the pkg-java-commits
mailing list