[
https://issues.apache.org/jira/browse/MJAVADOC-609?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Robert Scholte closed MJAVADOC-609.
-----------------------------------
Fix Version/s: 3.2.0
Assignee: Robert Scholte
Resolution: Fixed
> Include jars for which module name cannot be determined on the classpath
> ------------------------------------------------------------------------
>
> Key: MJAVADOC-609
> URL: https://issues.apache.org/jira/browse/MJAVADOC-609
> Project: Maven Javadoc Plugin
> Issue Type: Bug
> Components: javadoc
> Affects Versions: 3.1.0
> Reporter: Phil Clay
> Assignee: Robert Scholte
> Priority: Major
> Fix For: 3.2.0
>
>
> 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|https://docs.oracle.com/javase/9/docs/api/java/lang/module/ModuleFinder.html#of-java.nio.file.Path...-].
> When attempting to determine the module name of this jar, the following
> exception is encountered:
> {code:java}
> java.lang.module.FindException: Unable to derive module descriptor for
> C:\Users\foo\.m2\repository\com\bar\foo\ABC-1234-SNAPSHOT\foo-ABC-1234-SNAPSHOT.jar
> at java.base/jdk.internal.module.ModulePath.readJar(ModulePath.java:647)
> at
> java.base/jdk.internal.module.ModulePath.readModule(ModulePath.java:330)
> at java.base/jdk.internal.module.ModulePath.scan(ModulePath.java:236)
> at
> java.base/jdk.internal.module.ModulePath.scanNextEntry(ModulePath.java:189)
> at java.base/jdk.internal.module.ModulePath.findAll(ModulePath.java:165)
> at ModuleTest.test(ModuleTest.java:14)
> ... snip
> Caused by: java.lang.IllegalArgumentException: foo.ABC.1234.SNAPSHOT: Invalid
> module name: '1234' is not a Java identifier
> at
> java.base/jdk.internal.module.Checks.requireModuleName(Checks.java:52)
> at
> java.base/java.lang.module.ModuleDescriptor$Builder.<init>(ModuleDescriptor.java:1550)
> at
> java.base/java.lang.module.ModuleDescriptor.newAutomaticModule(ModuleDescriptor.java:2438)
> at
> java.base/jdk.internal.module.ModulePath.deriveModuleDescriptor(ModulePath.java:507)
> at java.base/jdk.internal.module.ModulePath.readJar(ModulePath.java:643)
> ... 44 more
> {code}
> The maven-javadoc-plugin will swallow this exception (without logging), and
> won't include the jar on the classpath.
> More specifically:
> # [{{AbstractJavadocMojo}} calls
> {{locationManager.resolvePaths(request)}}|https://github.com/apache/maven-javadoc-plugin/blob/58c0c6da6f23df9f48b319734dd87b1ce5106fd1/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java#L5144]
> # The returned {{ResolvePathsResult<File> result}} contains the swallowed
> exception in {{result.getPathExceptions()}}. The result does not include the
> file in [{{getModulepathElements()}} or
> {{getClasspathElements()}}|https://github.com/apache/maven-javadoc-plugin/blob/58c0c6da6f23df9f48b319734dd87b1ce5106fd1/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java#L5146-L5148]
> # 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.
> Potential solutions:
> This could potentially be solved in
> [plexus-java|https://github.com/codehaus-plexus/plexus-languages/blob/879376946165679eb3bb980ddaf8db68ab2031d4/plexus-java/src/main/java/org/codehaus/plexus/languages/java/jpms/LocationManager.java#L356],
> 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.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)