In maven-javadoc-plugin v3.1.0, dependency jars for which the module name cannot be determined are not included on the classpath when running the javadoc command. This leads to ClassNotFoundExceptions when running javadoc.
Here is a concrete example:
When developing features on feature branches, some developers include jira issue names in the version of artifacts... e.g. ABC-1234-SNAPSHOT. This leads to jar file names in the form foo-ABC-1234-SNAPSHOT.jar. Unfortunately, an automatic module name cannot be determined from the filename of this jar according to the rules of ModuleFinder. When attempting to determine the module name of this jar, the following exception is encountered:
The maven-javadoc-plugin will swallow this exception (without logging), and won't include the jar on the classpath.
- AbstractJavadocMojo calls locationManager.resolvePaths(request)
- The returned ResolvePathsResult<File> result contains the swallowed exception in result.getPathExceptions(). The result does not include the file in getModulepathElements() or getClasspathElements()
- The AbstractJavadocMojo ignores the path exceptions
- Therefore, the files that have path exceptions do not get included in the classpath or module path
- Later, this results in ClassNotFoundExceptions when running javadoc
One workaround is to not use the jira issue name in the version. However, this practice is extremely baked into our workflow (there is automation around it), and therefore would be very difficult to change.
I would like the maven-javadoc-plugin to include jars for which the automatic module name cannot be determined on the classpath.
This could potentially be solved in plexus-java, by having LocationManager.resolvePaths return jars for which the automatic module name cannot be determined as part of result.getClasspathElements()
Or, it could be solved it maven-javadoc-plugin by having AbstractJavadocMojo include any files from result.getPathExceptions() on the classpath by default.
Regardless of what is done, result.getPathExceptions() should not be totally swallowed by maven-javadoc-plugin. They should at least be logged to the debug logs. I had to remote debug in order to figure out why the jar was not being included on the classpath.