Henning Schmiedehausen created MJAVADOC-769:
-----------------------------------------------

             Summary: javadoc plugin can not deal with optional dependencies 
when building java 9+ javadocs
                 Key: MJAVADOC-769
                 URL: https://issues.apache.org/jira/browse/MJAVADOC-769
             Project: Maven Javadoc Plugin
          Issue Type: Bug
          Components: javadoc
    Affects Versions: 3.5.0
            Reporter: Henning Schmiedehausen


clone this repository: https://github.com/hgschmie/mjavadoc770

This builds an artifact, a tests artifact and a javadoc jar. 

When building this for Java 9+ compatibility (javadoc generate a list of 
modules) and using modules with Automatic-Module-Name enabled, the javadoc 
plugin can not access the optional dependencies:

{code}
ERROR] Exit code: 1
[ERROR] 
/Users/henning/scratch/mjavadoc770/src/main/java/mavenbugs/mjavadoc770/InternalImportBindingBuilder.java:88:
 error: cannot access Provider
[ERROR]     static final class InternalBindingProvider<T> implements 
Provider<T> {
[ERROR]                  ^
[ERROR]   class file for javax.inject.Provider not found
[ERROR] 1 error
[ERROR] Command line was: 
/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/javadoc 
-J-Xmx1024m @options @packages
{code}

Note that all other plugins (compiler, surefire) work fine. Just the javadoc 
plugin does not.

{code}
--add-modules
ALL-MODULE-PATH
--module-path
'/Users/henning/.m2/repository/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar:/Users/henning/.m2/repository/jakarta/inject/jakarta.inject-api/2.0.1.MR/jakarta.inject-api-2.0.1.MR.jar:/Users/henning/.m2/repository/com/google/inject/guice/5.1.0/guice-5.1.0.jar:/Users/henning/.m2/repository/com/google/errorprone/error_prone_annotations/2.11.0/error_prone_annotations-2.11.0.jar:/Users/henning/.m2/repository/com/google/guava/guava/31.1-jre/guava-31.1-jre.jar:/Users/henning/scratch/mjavadoc770/target/mjavadoc770-1.0-SNAPSHOT.jar'
--patch-module
mavenbugs.mjavadoc770='/Users/henning/scratch/mjavadoc770/src/main/java:/Users/henning/scratch/mjavadoc770/target/generated-sources/annotations:/Users/henning/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/henning/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:/Users/henning/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/Users/henning/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/Users/henning/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar:/Users/henning/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar'
-encoding
'UTF-8'
-public
-quiet
--release
11
-bottom
'Copyright &#169; 2023. All rights reserved.'
-charset
'UTF-8'
-d
'/Users/henning/scratch/mjavadoc770/target/apidocs'
-docencoding
'UTF-8'
-Xdoclint:none
-doctitle
'mjavadoc770 1.0-SNAPSHOT API'
-linkoffline
'https://docs.oracle.com/en/java/javase/11/docs/api' 
'/Users/henning/scratch/mjavadoc770/target/javadoc-bundle-options'
-nohelp
-use
-version
-windowtitle
'mjavadoc770 1.0-SNAPSHOT API'
{code}

The javadoc plugin decides that the "javax.inject-1.jar" is added to the 
classpath even though it is an optional dependency of the main module. Contrary 
to this, the jakarta.inject-api-2.0.1.MR.jar is added to the module path.

Neither of the modules is either an automatic (with an entry in 
META-INF/MANIFEST.MF) nor a full JPMS module (module-info). The plugin decided 
arbitrarily that one should go onto the class path and one onto the module path.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to