且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

package-info.java 包注释以影响所有类,包括子包中的类

更新时间:2023-01-10 12:25:02

看起来没有办法做到这一点.我为那些 package-info.java 添加了一个静态分析 checkstyle 检查,以确保它们始终存在.请参阅:http://checkstyle.sourceforge.net/config_javadoc.html 了解更多详情.然后,如果您对项目运行 checkstyle 静态分析,它会抱怨缺少 package-info.java 文件.

It looks like there is no way to do this. I have added a static analysis checkstyle check for those package-info.java to make sure they are always there. See: http://checkstyle.sourceforge.net/config_javadoc.html for more details. Then if you run checkstyle static analysis on the project, it will complain for any missing package-info.java file.

最后,要抑制测试中的 checkstyle 规则,以及存在包注释定义的包,请使用此抑制规则:

Finally, to suppress the checkstyle rule on the tests, and on the package where the package annotation definition exists use this suppression rule:

<suppress checks="JavadocPackage" files="PackageNonnull.java|[/\\]src[/\\]test[/\\]java[/\\]"/>