apache / apache/maven-javadoc-plugin
[MJAVADOC-768] javadoc has a hard time with JPMS and provided or optional module dependencies.
- Dominant language
- Java
- Stars
- 107
- Forks
- 116
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 16
Description
**[Henning Schmiedehausen](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=henning)** opened **[MJAVADOC-768](https://issues.apache.org/jira/browse/MJAVADOC-768?redirect=false)** and commented
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.
---
**Affects:** 3.5.0
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked mjavadoc768 reproduction and run `mvn clean install` from its root to confirm the aggregate-jar failure. Inspect the `module-info.java` files for thing1 and thing2 and the generated Javadoc options file; done means aggregation succeeds with provided and optional dependencies available on the module path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100