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/docs/api/ are in named modules.

Has anyone been able to make javadoc work without having to change the source version to 1.8 (as suggested in other forums)? I'm using JDK v11.0.5 and the issue still present (also with JDK 12+).

Edit: This error originated from maven and thrown by the maven-javadoc-plugin. I have not been able to make it work for JDK 11+ even with the <source>8</source> configuration.


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>

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


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>