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

javadoc:javadoc does not work when module-info.java is present but compile:compile has not been executed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 3.2.0, 3.3.0
    • None
    • javadoc
    • None

    Description

      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:

      <!-- 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>
      
      // src/main/java/Foo.java
      /** Foo */
      public class Foo { }
      

      Execute test without module-info.java works fine:

      $ mvn clean javadoc:javadoc
      ...
      [INFO] BUILD SUCCESS
      

      Now add module-info.java:

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

      Test again:

      $ 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.
      

      Test with compile step:

      $ mvn clean compile javadoc:javadoc
      [INFO] BUILD SUCCESS
      

      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.

      Attachments

        Issue Links

          Activity

            People

              rfscholte Robert Scholte
              t-8ch Thomas WeiƟschuh
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: