JDK 11+ and Javadoc

前端 未结 7 1982
Happy的楠姐
Happy的楠姐 2020-12-24 11:56
Exit code: 1 - javadoc: error - The code being documented uses packages in the unnamed module, but the packages defined in https://docs.oracle.com/en/java/javase/11/         


        
相关标签:
7条回答
  • 2020-12-24 11:59

    Adding <detectJavaApiLink>false</detectJavaApiLink> to the Maven javadoc pluging configuration fix the error

    0 讨论(0)
  • 2020-12-24 12:01

    I was able to get my own project to work by using a new version of the compiler plugin and setting the release property to 8.

    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
    </plugin>
    
    <properties>
        <maven.compiler.release>8</maven.compiler.release>
    </properties>
    
    0 讨论(0)
  • 2020-12-24 12:07

    I needed the bit from Carlos Santos to make this really work. The complete config that incorporates his answer is:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-javadoc-plugin</artifactId>
      <configuration>
        <source>8</source>
        <detectJavaApiLink>false</detectJavaApiLink>
      </configuration>
    </plugin>
    
    0 讨论(0)
  • 2020-12-24 12:14

    javadoc produces links to packages you use, e.g. to classes documented in .../javase/11/docs/api. While your comments are in an unnamed module, the targets are not, and javadoc can't combine those two. It produces either a package-list or an element-list file, so you can't mix unnamed modules (packages) with named modules.

    I didn't find a way to limit the links that javadoc tries to produce; so you may have to use modules for your own project. This seems ridiculous to me, just to make javadoc happy. I guess this is just one of the reasons that so many people stick to Java 8.

    0 讨论(0)
  • 2020-12-24 12:17

    As suggested in OpenJDK issue tracker this can be worked around with defining source on Javadoc plugin:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
            <source>8</source>
        </configuration>
    </plugin>
    
    0 讨论(0)
  • 2020-12-24 12:22

    I was facing the same issue. I was using Java 11.0.3 and org.apache.maven.plugins:maven-javadoc-plugin:2.10.4:jar. Updating the maven-javadoc-plugin version to 3.2.0 worked perfectly for me.

    0 讨论(0)
提交回复
热议问题