After adding module-info.java
files to my project my checkstyle plugin start failing with:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (default-cli) on project email: Failed during checkstyle configuration: NoViableAltException occurred during the analysis of file /home/xxx/IdeaProjects/blynk-server/server/notifications/email/src/main/java/module-info.java. unexpected token: module -> [Help 1]
I tried
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
However, it failed with:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (default-cli) on project blynk: Failed during checkstyle configuration: cannot initialize module BeforeExecutionExclusionFileFilter - Unable to instantiate 'BeforeExecutionExclusionFileFilter' class, it is also not possible to instantiate it as com.puppycrawl.tools.checkstyle.checks.annotation.BeforeExecutionExclusionFileFilter
What is the correct way for skipping module-info.java
files during checkstyle for maven-checkstyle-plugin?
It will also generate the violation report for the project which is available as a view in Eclipse. To view to violation report, go to Window -> Show View -> Other, and search for Checkstyle. Options for Violations and Violations Chart should be displayed.
Checkstyle is one of the most popular linters available. With this popularity comes regular updates, thorough documentation, and ample community support.
Not sure why the Checkstyle filter is not working (this reported bug seems very similar to yours and it was fixed in version 7.3.0, so maybe you need to update Checkstyle).
Anyway the Maven excludes
element is also supposed to do this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<excludes>**/module-info.java</excludes>
</configuration>
</plugin>
More in the plugin goal documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With