带有Maven的Java 11/12 Javadoc无法生成用于测试的Javadocs [英] Java 11/12 Javadoc with maven results in not generating Javadocs for tests

查看:221
本文介绍了带有Maven的Java 11/12 Javadoc无法生成用于测试的Javadocs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下结构的小项目:

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

在我的maven pom中,我还定义了javadoc插件,如下所示:

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]生成"Javadoc";报告--- maven-javadoc-plugin:3.1.0:aggregate-no-fork[错误]提取链接时出错:D:\ work \ eclipse \ java \ FritzBox \ phplib \ target \ javadoc-bundle-options.忽略它.

[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]生成"Test Javadoc";报告--- maven-javadoc-plugin:3.1.0:test-aggregate-no-fork

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

[错误]提取链接时出错:D:\ work \ eclipse \ java \ FritzBox \ phplib \ target \ javadoc-bundle-options.忽略它.

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

正在加载软件包de.ps.pl.te.test的源文件...

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

1个错误

[ERROR]创建javadoc报告时出错:

[ERROR] Error while creating javadoc report:

退出代码:2-javadoc:错误-软件包de.powerstat.phplib.templateengine.test没有源文件

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

命令行为:[...] javadoc.exe @options @packages

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

请参考"[...]"目录中生成的Javadoc文件.

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

org.apache.maven.reporting.MavenReportException:

org.apache.maven.reporting.MavenReportException:

退出代码:2-javadoc:错误-软件包de.ps.pl.te.test没有源文件

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

命令行为:[...] javadoc.exe @options @packages

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

请参考"[...] \ target \ site \ testapidocs"目录中的生成的Javadoc文件.

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

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

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

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

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

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

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

[...]

我研究了以下问题:

但是我的问题似乎有所不同,并且基于Java模块化.所以问题是如何解决-还是要报告错误?

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?

编辑1

现在我尝试使用JDK 11.0.3和JDK 12.0.1-由于Oracle证书和服务器问题,我无法下载OpenJDK-因此我无法测试OpenJDK 13的早期访问.

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.

有趣的是,使用11/12版本时,错误消息略有不同.

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

使用JDK 11时,错误是:

With JDK 11 the error is:

退出代码:1-Project \ src \ main \ java \ module-info.java:12:错误:找不到模块:org.apache.logging.log4j需要org.apache.logging.log4j;

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

使用JDK 12时,错误是:

With JDK 12 the error is:

退出代码:1-错误:找不到模块:de.powerstat.phplib.templateengine

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在多版本jar中不支持模块信息

我还试图排除模块info.java而不成功:

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>

编辑2

在target \ site \ apidocs内,我可以找到以下(是否生成过的文件?)文件:

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

  • argfile
  • javadoc.bat
  • 选项
  • 包装

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:

javadoc.bat:

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

软件包:

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

选项:

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

对于有人想亲自尝试的情况,我现在在中提供了整个项目.GitHub

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

通过更新到Java 11.0.10或其他更新版本,上述一些问题已消失.但是仍然存在一个问题-我报告为错误.

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.

推荐答案

在测试中看到此错误

[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

刚刚创建了文件夹"mkdir ./target/pit-reports",它消失了.这正在产生问题

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

<show>private</show>

所以我们可以说您在maven-javadoc-plugin中发现了一个错误:)

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

这篇关于带有Maven的Java 11/12 Javadoc无法生成用于测试的Javadocs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆