Thomas Weißschuh created MJAVADOC-665:
-----------------------------------------

             Summary: javadoc:javadoc does not work when module-info.java is 
present but compile:compile has not been executed
                 Key: MJAVADOC-665
                 URL: https://issues.apache.org/jira/browse/MJAVADOC-665
             Project: Maven Javadoc Plugin
          Issue Type: Bug
          Components: javadoc
    Affects Versions: 3.2.0, 3.2.1
            Reporter: Thomas Weißschuh


Tested with 3.2.0 and master 6afe4bdf2b2e62b81

When trying to execute "mvn javadoc:javadoc" without having executed "mvn 
compile" before the build fails with an error message.

Test environment:

{code:xml}
<!-- pom.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>example</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <java.compiler.release>11</java.compiler.release>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
{code}

{code:java}
// src/main/java/Foo.java
/** Foo */
public class Foo { }
{code}

Execute test without module-info.java works fine:

{code:sh}
$ mvn clean javadoc:javadoc
...
[INFO] BUILD SUCCESS
{code}

Now add module-info.java:

{code:sh}
// src/main/java/module-info.java
module org.example { }
{code}

Test again:

{code:sh}
$ mvn clean javadoc:javadoc
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc (default-cli) on 
project example: An error has occurred in Javadoc report generation:
[ERROR] Exit code: 1 - error: module not found: org.example
[ERROR]
[ERROR] Command line was: /usr/lib/jvm/java-11-openjdk/bin/javadoc @options 
@argfile
[ERROR]
[ERROR] Refer to the generated Javadoc files in 
'/tmp/testplug/target/site/apidocs' dir.
{code}

Test with compile step:

{code:sh}
$ mvn clean compile javadoc:javadoc
[INFO] BUILD SUCCESS
{code}

Looking into "target/site/apidocs/options" the parameters
"--module-source-path '/tmp/testplug/target/site/apidocs/src'" are passed to
the javadoc tool.
This directory contains a subdirectory for org.example which itself is empty
however.
If I manually symlink the module-info.class from my source directory to this
directory the next run of "mvn javadoc:javadoc" succeeds.

To me it seems AbstractJavadocMojo should link or copy the existing descriptor
there.




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

Reply via email to