[ 
https://issues.apache.org/jira/browse/MJAVADOC-645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17065323#comment-17065323
 ] 

Gili edited comment on MJAVADOC-645 at 3/24/20, 5:23 AM:
---------------------------------------------------------

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

{code:java}
<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>
{code}

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?


was (Author: cowwoc):
Fixed by adding:

{code:java}
<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>
{code}

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?

> Remind user to add Automatic-Module-Name entry when an unnamed module depends 
> on a named module
> -----------------------------------------------------------------------------------------------
>
>                 Key: MJAVADOC-645
>                 URL: https://issues.apache.org/jira/browse/MJAVADOC-645
>             Project: Maven Javadoc Plugin
>          Issue Type: Improvement
>          Components: jar, javadoc
>    Affects Versions: 3.2.0
>            Reporter: Gili
>            Priority: Major
>         Attachments: testcase.zip
>
>
> 1. Extract testcase
> 2. Run `mvn clean package`
> 3. Build fails with:
> {code:java}
> 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.
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to