Description
Check out this project: https://github.com/hgschmie/mjavadoc768/
run mvn clean install in the root. This results in this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.5.0:aggregate-jar (javadoc-jar) on project doc: MavenReportException: Error while generating Javadoc: [ERROR] Exit code: 1 [ERROR] /Users/henning/scratch/jdbug/thing2/src/main/java/module-info.java:4: error: module not found: jakarta.annotation [ERROR] requires static jakarta.annotation; [ERROR] ^ [ERROR] /Users/henning/scratch/jdbug/thing1/src/main/java/module-info.java:4: error: module not found: jakarta.annotation [ERROR] requires static jakarta.annotation; [ERROR] ^ [ERROR] 2 errors [ERROR] Command line was: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/javadoc -J-Xmx1024m @options @packages @argfile [ERROR] [ERROR] Refer to the generated Javadoc files in '/Users/henning/scratch/jdbug/doc/target/apidocs' dir.
The problem is that both maven modules (thing1 and thing2) declare a compile time dependency on "jakarta-annotation" using either maven provided scope or maven optional. This is reflected in the JPMS module descriptor by using `required static jakarta.annotation;`.
But the javadoc tool, when it wants to generate the aggregation jar, generates an options file that does not contain the jakarta-annotation jar on the module path (which is needed for javadoc to succeed), so the tool reports the error above. The javadoc tool needs to add all provided and optional dependencies to the module path for the aggregated jar.