checkstyle中Javadoc包的使用
我正在将 checkstyle 版本 4.0 配置转换为版本 5.0。因此,我添加了以下内容来替换旧的“PackageHtml”,
发生的情况是,我收到一条信息消息,指出“Missing package-info.java”,即使我的 java 文件顶部有以下注释,
/* * 文件:测试.java * 系统:PF工具 * 模块:com.research.usage * 作者: 贾达伊 * 版权所有:Jadaaih * 最后修改者: jadaaih * 日期: 2009-03-02 15:30:24 * 版本:1.1 * 描述: * 前提条件: */
很抱歉显示失真,注释末尾有换行符。
请告知如何摆脱 Checkstyle 5.0 中与 4.0 兼容的 checkstyle 信息消息。
I am in the process of converting my checkstyle version 4.0 configurations to version 5.0. Hence, I have added the following to replace older "PackageHtml",
<module name="JavadocPackage">
<metadata name="com.atlassw.tools.eclipse.checkstyle.lastEnabledSeverity" value="info"/>
<property name="allowLegacy" value="true"/>
<property name="severity" value="info"/>
</module>
What happens is, I get a info message saying "Missing package-info.java" even though I have the following comments on top of my java file,
/*
* File: Test.java
* System: PF Tools
* Module: com.research.usage
* Author: jadaaih
* Copyright: Jadaaih
* Last modified by: jadaaih
* Date: 2009-03-02 15:30:24
* Version: 1.1
* Description:
* Preconditions:
*/
I am sorry the display is distorted, the comments have newline at the end.
Please advise on how to get rid of that checkstyle info message in Checkstyle 5.0 compliant with 4.0.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
浏览文档,在我看来,您的元数据元素毫无意义。也许它甚至会引起 checkstyle 解析器忽略 JavadocPackage 配置。
此外,当设置了allowLegacy 属性(默认情况下为 false)时,您指定要使用package.html 文件。 不允许同时拥有package.html和package-info.java文件。
编辑:
我刚刚测试了上面的内容。看来这个错误是有误导性的。它实际上的意思是缺少package.html文件:)只需添加它,警告就会消失。
Browsing the documentation it looks to me that your metadata element is pointless. Perhaps it even provokes the checkstyle parser to ignore the JavadocPackage configuration.
Also, when the allowLegacy property is set (it's false by default), you specify that you want to use a package.html file. It is not allowed to have both a package.html and package-info.java files.
Edit:
I have just tested the above. It seems that the error is misleading. What it actually means is that a package.html file is missing :) Just add it and the warning will disappear.
就我而言,它只是缺少特定包内的文件 package-info.java 。
由于我使用 Eclipse,因此我通过创建一个新包来创建它,勾选“Create package-info.java”框,然后将 package-info.java 移动到我收到 Checkstyle 警告的包中。如果不使用 Eclipse,那么您可以手动创建一个名为 package-info.java 的文件。
我的 package-info.java 的内容看起来像
干杯!
In my case it was just missing the file package-info.java inside the particular package.
Since I use Eclipse, I have created it by creating a new package, ticking the box "Create package-info.java" and then moving the package-info.java into the package where I was getting the Checkstyle warning. If not using Eclipse then you can manually create a file called package-info.java.
The content of my package-info.java looks like
Cheers!
package-info.java
是一个单独的 java 文件,用于包级文档。您可以手动创建一个,它只包含有关您的包将具有的 java 文件的任何信息。此信息将成为生成的 javadoc 的一部分。如果您使用的是 eclipse 或 netbeans 等 IDE,则在创建新包时会出现一个选项,如下所示 -
该文件如下所示 -
The
package-info.java
is a separate java file that is used for package-level documentation. You can manually create one, it simply contains any information about the java files that your package is going to have. This information will be a part of the generated javadoc.If you're using an IDE like eclipse or netbeans, you get an option while you create a new package, like this -
The file looks like this-