eclipse - 使用 Ant 编译时增加 javadoc 警告的最大数量

标签 eclipse ant java-8 javadoc eclipse-mars

我最近将我的开发环境从 Java 7 升级到 Java 8,现在发现了大量以前未检测到的 javadoc 问题。

默认情况下,Ant(通过 Eclipse Mars 调用)将其警告(我假设有错误)限制为 100:

Ant warnings limited to 100

是否有任何参数强制 Ant 显示 全部 javadoc 警告而不是限制为 100?

我试图使用 -Xmaxwarns 1000参数通过 compilerarg元素,但似乎 Eclipse Mars (Ant 1.9.4) 中的当前 Ant 版本javadoc task不支持compilerarg元素(仅在 javac task 中受支持):

<!-- Generate the API documentation. -->
<target name="javadoc" depends="clean" description="Generate the API documentation.">

    <!-- Create the build directory structure used by javadoc. -->
    <mkdir dir="${build.folder}" />
    <mkdir dir="${docs.folder}" />

    <!-- Run javadoc. -->

    <javadoc destdir="${docs.folder}/api" author="true" version="true" use="true" windowtitle="${documentation.title}">

        <compilerarg value="-Xmaxerrs 1000 -Xmaxwarns 1000" />

        <classpath>

        ...

ant: javadoc doesn't support the nested "compilerarg" element.

Java 8 javadoc确实支持这些参数(在 Java 7 b100 中添加了支持):
C:\>javadoc -X
  -Xmaxerrs <number>               Set the maximum number of errors to print
  -Xmaxwarns <number>              Set the maximum number of warnings to print

Provided by standard doclet:
  -Xdocrootparent <url>            Replaces all appearances of @docRoot followed

                                   by /.. in doc comments with <url>
  -Xdoclint                        Enable recommended checks for problems in javadoc comments
  -Xdoclint:(all|none|[-]<group>)
        Enable or disable specific checks for problems in javadoc comments,
        where <group> is one of accessibility, html, missing, reference, or syntax.

These options are non-standard and subject to change without notice.

结论:看来 Ant javadoc任务是这里的限制因素,如果它支持 compilerarg标志,可以调整错误和警告的限制。

最佳答案

正如您所指出的,-Xmaxwarns影响 javadoc 的警告数量程序输出。
-Xmaxwarns可以传递给javadoc嵌套程序 <arg>元素:

<javadoc ...>
    <arg value="-Xmaxwarns"/>
    <arg value="200"/>
</javadoc>

在我自己的测试用例中,我能够将报告的警告增加到 100 以上:

[javadoc] Generating Javadoc
...
[javadoc] 112 warnings

关于eclipse - 使用 Ant 编译时增加 javadoc 警告的最大数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32642447/

相关文章:

java - Mavenizing Netbeans 平台应用程序,这可能吗?

java - 在两个列表上使用 java 流进行左连接

java - CompletableFuture | thenApplyAsync 与 thenCompose 及其用例

android - 重新安装jre和jdk后eclipse无法运行

java - log4j 无法写入文件

apache-flex - 为什么 Flash Builder 4 使用 Flash Player 而不是浏览器来运行应用程序?

java - 检查 `Stream` 的所有元素是否相同

java - 在 Eclipse 中访问图像路径

java - 如何将junit测试分发到另一台机器

java - 什么是 org.eclipse.wst.common.component 以及如何将它用于 ant