java9-modularity / gradle-modules-plugin

This Gradle plugin helps working with the Java Platform Module System
https://javamodularity.com/
MIT License
234 stars 36 forks source link

Javadoc task fails (module not found) #75

Closed mpe85 closed 5 years ago

mpe85 commented 5 years ago

The dependencies are configured like this:

dependencies {
    implementation(
        [...]
        'net.bytebuddy:byte-buddy:1.9.11',
        [...]
    )
    [...]
}

The module-info.java looks like this:

open module [...] {
    [...]
    requires net.bytebuddy;
    [...]
}

It results in an error when executing the javadoc task:

[...]\src\main\java\module-info.java:3: error: module not found: net.bytebuddy
requires net.bytebuddy;

ByteBuddy is a multi release jar with the module-info.class inside META-INF/versions/9

Seems to be related to this issue which is already closed: https://github.com/java9-modularity/gradle-modules-plugin/issues/13

RovoMe commented 5 years ago

I've stumbled into this issue yesterday and even though I use Maven and not Gradle, I think the core issue resolves around the javadoc binary not being able to work well with multi-release JARs.

One of my project, which I am upgrading to Java 11 (including module support), has a requires org.slf4j; directive inside the module-info.java file of one of the sub-modules.

A lookup of the contents of the slf4j-api library via jar -tf mods\slf4j-api-1.8.0-beta4.jar reveals the following content:

META-INF/
META-INF/MANIFEST.MF
META-INF/versions/
META-INF/versions/9/
org/
org/slf4j/
org/slf4j/event/
org/slf4j/helpers/
org/slf4j/spi/
META-INF/versions/9/module-info.class
org/slf4j/event/EventConstants.class
org/slf4j/event/EventRecodingLogger.class
org/slf4j/event/Level.class
org/slf4j/event/LoggingEvent.class
org/slf4j/event/SubstituteLoggingEvent.class
org/slf4j/helpers/BasicMarker.class
org/slf4j/helpers/BasicMarkerFactory.class
org/slf4j/helpers/BasicMDCAdapter$1.class
org/slf4j/helpers/BasicMDCAdapter.class
org/slf4j/helpers/FormattingTuple.class
org/slf4j/helpers/MarkerIgnoringBase.class
org/slf4j/helpers/MessageFormatter.class
org/slf4j/helpers/NamedLoggerBase.class
org/slf4j/helpers/NOPLogger.class
org/slf4j/helpers/NOPLoggerFactory.class
org/slf4j/helpers/NOPMDCAdapter.class
org/slf4j/helpers/NOPServiceProvider.class
org/slf4j/helpers/SubstituteLogger.class
org/slf4j/helpers/SubstituteLoggerFactory.class
org/slf4j/helpers/SubstituteServiceProvider.class
org/slf4j/helpers/Util$1.class
org/slf4j/helpers/Util$ClassContextSecurityManager.class
org/slf4j/helpers/Util.class
org/slf4j/ILoggerFactory.class
org/slf4j/IMarkerFactory.class
org/slf4j/Logger.class
org/slf4j/LoggerFactory.class
org/slf4j/LoggerFactoryFriend.class
org/slf4j/Marker.class
org/slf4j/MarkerFactory.class
org/slf4j/MDC$1.class
org/slf4j/MDC$MDCCloseable.class
org/slf4j/MDC.class
org/slf4j/spi/LocationAwareLogger.class
org/slf4j/spi/LoggerFactoryBinder.class
org/slf4j/spi/MarkerFactoryBinder.class
org/slf4j/spi/MDCAdapter.class
org/slf4j/spi/SLF4JServiceProvider.class
META-INF/maven/
META-INF/maven/org.slf4j/
META-INF/maven/org.slf4j/slf4j-api/
META-INF/maven/org.slf4j/slf4j-api/pom.xml
META-INF/maven/org.slf4j/slf4j-api/pom.properties

Via java --module-path mods\ --describe-module org.slf4j I also see the module configuration of that library:

exports org.slf4j
exports org.slf4j.event
exports org.slf4j.helpers
exports org.slf4j.spi
requires java.base mandated
uses org.slf4j.spi.SLF4JServiceProvider

which is identical to what I get if I enter jar -f mods\slf4j-api-1.8.0-beta4.jar --describe-module --release 9. So this JAR is definitely a multi-release archive.

If I attempt to create JavaDoc for that module I get the error: module not found: org.slf4j failure. I even get the same error on attempting the JavaDoc manually with a command similar to this

javadoc --module-path "..\..\..\mods\logback-classic-1.3.0-alpha4.jar;..\..\..\mods\logback-core-1.3.0-alpha4;..\..\..\mods\slf4j-api-1.8.0-beta4.jar;mods\myproject-commons-0.0.1-SNAPSHOT.jar;..\..\..\mods\myproject-0.0.1-SNAPSHOT.jar" --module-source-path . -d ..\..\apidocs com.acme.test .\module-info.java

when executed from inside the src\main\java directory of that module on a Windows 10 computer. Note that I've copied the respective modules that project requires to a dedicated mods folder in the base project.

If I comment out the requires org.slf4j; line in the module-info.java file the command above successfully generates the JavaDoc of that module. I'm therefore quite sure that the actual problem is located within the javadoc binary.

sjoerdtalsma commented 5 years ago

I came across this issue and started a quick search.\ It is known with the JDK people and has been fixed: JDK-8208269.

Supposedly the fix was backported to JDK version 11.0.5 as well (long-time support)

tlinkowski commented 5 years ago

@mpe85 @RovoMe Can you confirm that it works with JDK 11.0.5, as @sjoerdtalsma suggests?

paulbakker commented 5 years ago

Closing because of inactivity. Issue doesn't seem to be related with the plugin.

renatoathaydes commented 3 years ago

@tlinkowski I can confirm that at least in my case, upgrading from Java 11.0.2 to the latest (11.0.13 as of today) resolved the issue I was having that was very similar to this one, even though I don't even use this plugin.