B. Stackhouse
B. Stackhouse

Reputation: 577

JavaDoc with Maven generates 'Error fetching link:'

Generating a JavaDoc with Maven I get an error message 'Error fetching link:' referring to a file javadoc-bundle-options. In it it contains javadocResourcesDirectory with a directory. Even if I create that directory I still get the same error. How can I correct the error?

    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.2.0</version>
    <configuration>
        <show>public</show>
        <quiet>true</quiet>
        <doctitle>${project.name}</doctitle>
        <sourceFileExcludes>**/tests/**/*.java</sourceFileExcludes>
        <links>
            <link>https://docs.oracle.com/en/java/javase/14/docs/api/</link>
        </links>
        <javadocDirectory>javadoc/resources</javadocDirectory>
   </configuration>
    <executions>
        <execution>
            <id>javadocs-jar</id>
            <phase>package</phase>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

    <?xml version="1.0" encoding="UTF-8"?>
<javadocOptions>
  <docletArtifacts>
    <docletArtifact />
  </docletArtifacts>
  <tagletArtifacts>
    <tagletArtifact />
  </tagletArtifacts>
  <links>
    <link>https://docs.oracle.com/en/java/javase/14/docs/api/</link>
  </links>
  <javadocResourcesDirectory>javadoc/resources</javadocResourcesDirectory>
</javadocOptions>

Upvotes: 10

Views: 3449

Answers (1)

Osmund Francis
Osmund Francis

Reputation: 821

According to the Apache Maven Issue: https://issues.apache.org/jira/browse/MJAVADOC-623 this is a bug in the Maven JavaDoc Plugin version 3.1.1.

You can "correct" the error by trying to use version 3.1.0, or use the fixed version of the plugin when it is released (at time of writing this, it still hasn't been released).

EDIT (1):

A workaround is to add the maven.compiler.release property to the Maven project file:

<project>
  <properties>
    <maven.compiler.release>11</maven.compiler.release>
  </properties>
</project>

EDIT (2):

A workaround is to specify the Java release in the Maven JavaDoc Plugin:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-javadoc-plugin</artifactId>
  <version>3.2.0</version>
  <executions>
    <execution>
      <id>main-javadoc</id>
      <phase>package</phase>
      <goals>
        <goal>jar</goal>
      </goals>
      <configuration>
        <release>11</release>
      </configuration>
    </execution>
  </executions>
</plugin>

Upvotes: 4

Related Questions