Reputation: 2089
I want to apply an annotation on all of my classes and I am trying the best way to do so. So far I am stuck with the package-info.java file that can annotate a whole package, but not the class files contained in the sub-packages. Is there a more efficient way other than adding 100 identical package-info.java files in my project that only contain a single annotation?
thanks
Upvotes: 7
Views: 2918
Reputation: 2089
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.
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[/\\]"/>
Upvotes: 3