Javadoc:将警告视为错误?

发布于 2024-12-19 13:51:11 字数 351 浏览 1 评论 0 原文

使用 Javadoc 时是否可以将警告视为错误?特别是,我从 Ant 调用 Javadoc 并在我的 任务上设置了 failonerror="true" ,但我似乎无法触发此操作。尽管 javadoc 正在生成警告,但当 Ant 完成时,我仍然得到 BUILD SUCCESSFUL ,退出代码为 0

我希望能够向 任务的 additionalparam 属性添加一些内容,以强制 Javadoc 警告失败。

Is it possible to treat warnings as errors when using Javadoc? In particular, I am calling Javadoc from Ant and have failonerror="true" set on my <javadoc> task, but I cannot seem to trigger this. Even though javadoc is generating warnings, I am still getting BUILD SUCCESSFUL with an exit code of 0 when Ant completes.

I would expect to be able to add something to the additionalparam attribute of the <javadoc> task to force a failure for Javadoc warnings.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

喜爱纠缠 2024-12-26 13:51:11

我知道这已经很旧了,但对于像我一样寻找答案的人来说可能仍然有帮助。如果它不起作用,请将 更改

<contains text="warnings"/>

为您在输出中看到的文本。

<target name="javadoc">
<delete dir="${jDocDirectory}"/> 
<mkdir dir="${jDocDirectory}"/> 
<record name="javadocLog" action="start"/>
<javadoc (settings, blah blah) />
<record name="javadocLog" action="stop"/>
        <condition property="javadoc.warnings">
            <isfileselected file="javadocLog">
                <contains text="warnings"/>
             </isfileselected>
        </condition>
        <fail if="javadoc.warnings">Javadoc warnings!</fail>
</target>

编辑:
如果您有一个警告,这将不起作用,要修复所有警告,您必须更改此设置:

<contains text="warnings"/>

I know this is old but it might still be helpful for someone looking for the answer like I was. If it doesn't work change the

<contains text="warnings"/>

to the text you see with your output.

<target name="javadoc">
<delete dir="${jDocDirectory}"/> 
<mkdir dir="${jDocDirectory}"/> 
<record name="javadocLog" action="start"/>
<javadoc (settings, blah blah) />
<record name="javadocLog" action="stop"/>
        <condition property="javadoc.warnings">
            <isfileselected file="javadocLog">
                <contains text="warnings"/>
             </isfileselected>
        </condition>
        <fail if="javadoc.warnings">Javadoc warnings!</fail>
</target>

edit:
If you have one warning this will not work, to fix for ALL warnings you must change this:

<contains text="warnings"/>
ㄟ。诗瑗 2024-12-26 13:51:11

Ant 1.9.4 现在有failonwarning =“true”

http://ant.apache.org/手册/任务/javadoc.html

Ant 1.9.4 now has failonwarning="true"

http://ant.apache.org/manual/Tasks/javadoc.html

醉南桥 2024-12-26 13:51:11

我不知道 JavaDoc 参数,我建议在 ant 构建中使用 checkstyle 这样的工具像这样。您可以将其设置为在出现 Javadoc 警告时失败。

I don't know about a JavaDoc parameter, I would recommend using a tool like checkstyle in your ant build for things like this. You can set it up to fail on Javadoc warnings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文