Uploaded image for project: 'Maven Javadoc Plugin'
  1. Maven Javadoc Plugin
  2. MJAVADOC-645

Remind user to add Automatic-Module-Name entry when an unnamed module depends on a named module

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 3.2.0
    • None
    • jar, javadoc
    • None

    Description

      1. Extract testcase
      2. Run `mvn clean package`
      3. Build fails with:

      Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:jar (attach-javadocs) on project module2: MavenReportException: Error while generating Javadoc: 
      Exit code: 1 - javadoc: error - The code being documented uses packages in the unnamed module, but the packages defined in http://nexus.sonatype.org/oss-repository-hosting.html/root/module1/apidocs/ are in named modules.
      
      Command line was: cmd.exe /X /C ""C:\Program Files\Java\jdk-14+36-1461\bin\javadoc.exe" @options @packages"
      
      Refer to the generated Javadoc files in 'C:\Users\Gili\Documents\3rdparty\javadoc-jar-mixing-named-and-unnamed-extending-sonatype\module2\target\apidocs' dir.
      

      Attachments

        1. testcase.zip
          4 kB
          Gili

        Issue Links

          Activity

            rfscholte Robert Scholte added a comment -

            Looks like issues have been fixed in OpenJDK 15, so let's close it here.

            rfscholte Robert Scholte added a comment - Looks like issues have been fixed in OpenJDK 15, so let's close it here.
            cowwoc Gili added a comment -

            My bug report is now accessible at https://bugs.openjdk.java.net/browse/JDK-8241640

            cowwoc Gili added a comment - My bug report is now accessible at https://bugs.openjdk.java.net/browse/JDK-8241640
            rfscholte Robert Scholte added a comment -

            I've added the "apache-maven-interest" label and added myself as watcher.

            rfscholte Robert Scholte added a comment - I've added the "apache-maven-interest" label and added myself as watcher.
            cowwoc Gili added a comment -

            FYI, I filed a bug report with CAP and was told there are two related reports already under investigation:

            https://bugs.openjdk.java.net/browse/JDK-8240169
            https://bugs.openjdk.java.net/browse/JDK-8240232

            I'll link to my own bug report when it becomes public. It discusses failing-fast (outputting no files on failure) as you requested as well.

            cowwoc Gili added a comment - FYI, I filed a bug report with CAP and was told there are two related reports already under investigation: https://bugs.openjdk.java.net/browse/JDK-8240169 https://bugs.openjdk.java.net/browse/JDK-8240232 I'll link to my own bug report when it becomes public. It discusses failing-fast (outputting no files on failure) as you requested as well.
            rfscholte Robert Scholte added a comment -

            Based on the module2/target/apidocs/options I don't see anything weird: it doesn't mention the module path nor other module system related arguments.
            The stupid thing is that the pages are generated. IIRC I discussed this on the javadoc dev list, but I can't find any related issue labelled with "apache-maven-found" or "apache-maven-interest" ( https://bugs.openjdk.java.net/issues?jql=labels%20%3D%20apache-maven-found / https://bugs.openjdk.java.net/issues?jql=labels%20%3D%20apache-maven-interest )
            The fact that there's an error (breaking the build) AND that the pages are generated is just not good and IMO should be fixed in the javadoc tool.
            The error message is slightly different compared to https://bugs.openjdk.java.net/browse/JDK-8235202 and https://bugs.openjdk.java.net/browse/JDK-8212233

            rfscholte Robert Scholte added a comment - Based on the module2/target/apidocs/options I don't see anything weird: it doesn't mention the module path nor other module system related arguments. The stupid thing is that the pages are generated. IIRC I discussed this on the javadoc dev list, but I can't find any related issue labelled with "apache-maven-found" or "apache-maven-interest" ( https://bugs.openjdk.java.net/issues?jql=labels%20%3D%20apache-maven-found / https://bugs.openjdk.java.net/issues?jql=labels%20%3D%20apache-maven-interest ) The fact that there's an error (breaking the build) AND that the pages are generated is just not good and IMO should be fixed in the javadoc tool. The error message is slightly different compared to https://bugs.openjdk.java.net/browse/JDK-8235202 and https://bugs.openjdk.java.net/browse/JDK-8212233
            cowwoc Gili added a comment -

            I believe the issue is more involved than this. The javadoc tool expects
            both ends to be named or unnamed modules and they don't seem to be willing
            to improve this. The maven plugin looks for Automatic-Module-Name and uses
            --patch-module to tell the Javadoc tool that the unnamed module is actually
            named.

            Seeing as the bridge exists in the plugin, the warning would have to be in
            the plugin as well. At least that's my interpretation, Robert would know
            more.

            cowwoc Gili added a comment - I believe the issue is more involved than this. The javadoc tool expects both ends to be named or unnamed modules and they don't seem to be willing to improve this. The maven plugin looks for Automatic-Module-Name and uses --patch-module to tell the Javadoc tool that the unnamed module is actually named. Seeing as the bridge exists in the plugin, the warning would have to be in the plugin as well. At least that's my interpretation, Robert would know more.
            michael-o Michael Osipov added a comment - - edited

            We should fix the root cause, not the symptom: javadoc(1). Please report this on the Javadoc mailing list first.

            michael-o Michael Osipov added a comment - - edited We should fix the root cause, not the symptom: javadoc(1) . Please report this on the Javadoc mailing list first.
            cowwoc Gili added a comment - - edited

            Turns out this had nothing to do with the sonatype parent POM. I fixed the problem by adding:

            <plugin>
            	<groupId>org.apache.maven.plugins</groupId>
            	<artifactId>maven-jar-plugin</artifactId>
            	<configuration>
            		<archive>
            			<manifestEntries>
            				<Automatic-Module-Name>module2</Automatic-Module-Name>
            			</manifestEntries>
            		</archive>
            	</configuration>
            </plugin>
            

            In other words, if an unnamed module depends upon a named module, then one must set the Automatic-Module-Name entry in the JAR manifest; otherwise, the javadoc tool will fail with the aforementioned error.

            This is extremely unintuitive. I only got it working because I had an old bug report I filed last year and I saw how I fixed this problem then. Can we please add a check to maven-javadoc-plugin for this situation and output an error message that will point users in the right direction?

            cowwoc Gili added a comment - - edited Turns out this had nothing to do with the sonatype parent POM. I fixed the problem by adding: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifestEntries> <Automatic-Module-Name>module2</Automatic-Module-Name> </manifestEntries> </archive> </configuration> </plugin> In other words, if an unnamed module depends upon a named module, then one must set the Automatic-Module-Name entry in the JAR manifest; otherwise, the javadoc tool will fail with the aforementioned error. This is extremely unintuitive. I only got it working because I had an old bug report I filed last year and I saw how I fixed this problem then. Can we please add a check to maven-javadoc-plugin for this situation and output an error message that will point users in the right direction?
            michael-o Michael Osipov added a comment -

            Not w/o testing...

            michael-o Michael Osipov added a comment - Not w/o testing...
            cowwoc Gili added a comment -

            Any idea why the testcase is failing though?

            cowwoc Gili added a comment - Any idea why the testcase is failing though?
            michael-o Michael Osipov added a comment -

            cowwoc, no you don't. There is no obligation to inherit from oss-parent. I ditched it many years ago when they did not react on my issues.

            michael-o Michael Osipov added a comment - cowwoc , no you don't. There is no obligation to inherit from oss-parent. I ditched it many years ago when they did not react on my issues.
            cowwoc Gili added a comment -

            If I don't inherit from the sonatype POM, the error goes away. But I need to inherit from the parent POM to publish on their servers.

            cowwoc Gili added a comment - If I don't inherit from the sonatype POM, the error goes away. But I need to inherit from the parent POM to publish on their servers.
            cowwoc Gili added a comment -

            I'm running this on Windows 10.0.18363.720, JDK 14+36-1461 but earlier JDKs (e.g. 13) had the same problem.

            rfscholte This sounds a lot like the issues we fixed last year.

            If you run the `javadoc` goal instead of `jar` you get the following error instead:

            `Exit code: 1 - error: module not found: module1` but the module is clearly there.

            cowwoc Gili added a comment - I'm running this on Windows 10.0.18363.720, JDK 14+36-1461 but earlier JDKs (e.g. 13) had the same problem. rfscholte This sounds a lot like the issues we fixed last year. If you run the `javadoc` goal instead of `jar` you get the following error instead: `Exit code: 1 - error: module not found: module1` but the module is clearly there.

            People

              rfscholte Robert Scholte
              cowwoc Gili
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: