Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 11/12 Javadoc with maven results in not generating Javadocs for tests

I have a small project with the following structure:

pom.xml

src/main/java/
  module-info.java
  de.ps.pl.te/
    package-info.java
    TE.java

src/test/java/
   de.ps.pl.te.test/
     package-info.java
     TETests.java

Also within my maven pom I defined the javadoc plugin as follows:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <show>protected</show>
          <failOnError>false</failOnError>
        </configuration>
      </plugin>

Now I got some strange outputs during running

mvn clean install site

[INFO] Generating "Javadoc" report --- maven-javadoc-plugin:3.1.0:aggregate-no-fork [ERROR] Error fetching link: D:\work\eclipse\java\FritzBox\phplib\target\javadoc-bundle-options. Ignored it.

[...]

[INFO] Generating "Test Javadoc" report --- maven-javadoc-plugin:3.1.0:test-aggregate-no-fork

[ERROR] Error fetching link: D:\work\eclipse\java\FritzBox\phplib\target\javadoc-bundle-options. Ignored it.

Loading source files for package de.ps.pl.te.test...

1 error

[ERROR] Error while creating javadoc report:

Exit code: 2 - javadoc: error - No source files for package de.powerstat.phplib.templateengine.test

Command line was: [...]javadoc.exe @options @packages

Refer to the generated Javadoc files in '[...]' dir.

org.apache.maven.reporting.MavenReportException:

Exit code: 2 - javadoc: error - No source files for package de.ps.pl.te.test

Command line was: [...]javadoc.exe @options @packages

Refer to the generated Javadoc files in '[...]\target\site\testapidocs' dir.

at org.apache.maven.plugins.javadoc.AbstractJavadocMojo.executeJavadocCommandLine (AbstractJavadocMojo.java:5761)

at org.apache.maven.plugins.javadoc.AbstractJavadocMojo.executeReport (AbstractJavadocMojo.java:2148)

at org.apache.maven.plugins.javadoc.TestJavadocReport.executeReport (TestJavadocReport.java:162)

[...]

I studied the following question:

  • Maven, javadoc : No source files for package

But my problem seems to be different and based on java modularisation. So the question is how to fix it - or is it more to make a bug report?

EDIT 1

Now I tried with JDK 11.0.3 and JDK 12.0.1 - I was unable to download OpenJDK because of oracle certificate and server problems - so I could not test OpenJDK 13 early access.

The interesting point is that the error message differs slighly when using version 11/12.

With JDK 11 the error is:

Exit code: 1 - Project\src\main\java\module-info.java:12: error: module not found: org.apache.logging.log4j requires org.apache.logging.log4j;

With JDK 12 the error is:

Exit code: 1 - error: module not found: de.powerstat.phplib.templateengine

The rest of the message is still the same.

Also I found a bug report that might be involved here:

Javadoc does not support module-info in a multi-release jar

Also I tried to exclude the module-info.java without success:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-javadoc-plugin</artifactId>
  <version>3.1.0</version>
  <configuration>
    <show>protected</show>
    <failOnError>false</failOnError>
    <sourceFileExcludes>
      <sourceFileExclude>**/module-info.java</sourceFileExclude>
    </sourceFileExcludes>
  </configuration>
</plugin>

EDIT 2

Within target\site\apidocs I could finde the following (maven generated?) files:

  • argfile
  • javadoc.bat
  • options
  • packages

argfile:

'D:/TemplateEngine/src/main/java/de/ps/pl/te/package-info.java'
'D:/TemplateEngine/src/main/java/de/ps/pl/te/TemplateEngine.java'

javadoc.bat:

D:\Programme\Java\jdk-11.0.3\bin\javadoc.exe @options @argfile

packages:

de.powerstat.phplib.templateengine
de.powerstat.phplib.templateengine

options:

--module-path
'C:/.m2/repository/org/apache/logging/log4j/log4j-api/2.11.2/log4j-api-2.11.2.jar;C:/.m2/repository/org/apache/logging/log4j/log4j-core/2.11.2/log4j-core-2.11.2.jar'
-sourcepath
'D:/TemplateEngine/src/main/java'
-d
'D:/TemplateEngine/target/site/apidocs'
-linkoffline
'https://docs.oracle.com/en/java/javase/11/docs/api' 'D:/TemplateEngine/target/javadoc-bundle-options'
[Removed uninteresting parts like encoding, title etc.]

For the case that someone would like to try it him-/herself I have made the whole project now available at GitHub

EDIT 3:

Some of the above mentioned problems have been vanished with updating to Java 11.0.10 or other newer versions. But still one problem is around - which I have reported as a bug.

like image 584
PowerStat Avatar asked Apr 14 '19 14:04

PowerStat


1 Answers

While testing I seen this error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.7.1:site (default-site) on project templateengine: Execution default-site of goal org.apache.maven.plugins:maven-site-plugin:3.7.1:site failed: could not find reports directory [C:\tmp\TemplateEngine\target\pit-reports]
[ERROR]
[ERROR] Please copy and paste the information and the complete stacktrace below when reporting an issue
[ERROR] VM : OpenJDK 64-Bit Server VM
[ERROR] Vendor : Oracle Corporation
[ERROR] Version : 12.0.1+12
[ERROR] Uptime : 146619
[ERROR] Input ->
[ERROR]  1 : -Dclassworlds.conf=C:/ProgramData/chocolatey/lib/maven/apache-maven-3.6.1/bin/m2.conf
[ERROR]  2 : -Dmaven.home=C:/ProgramData/chocolatey/lib/maven/apache-maven-3.6.1
[ERROR]  3 : -Dlibrary.jansi.path=C:/ProgramData/chocolatey/lib/maven/apache-maven-3.6.1/lib/jansi-native
[ERROR]  4 : -Dmaven.multiModuleProjectDirectory=C:/tmp/TemplateEngine
[ERROR] BootClassPathSupported : false

just created the folder "mkdir ./target/pit-reports" and it went away. this is generating the problem

<show>private</show>

So we can say you found a bug in maven-javadoc-plugin :)

like image 73
ozkanpakdil Avatar answered Oct 16 '22 10:10

ozkanpakdil