我正在使用 Maven 和 Checkstyle 来检查我的代码质量。尽管我想在 CheckStyle 中关闭一些功能。
有一个模块负责处理尾随空格。它给出的评论是:
Line has trailing spaces.
现在我假设处理该问题的模块称为 RegexpSingleline,我想将其关闭。我已经尝试取消注释 ./myproject/target/checkstyle-checker.xml
中的文件,但是当我运行 mvn site
时,该文件会再次自动生成,并且我的更改它消失了。
我如何关闭这个模块?
最佳答案
您应该复制 checkstyle-checker.xml
文档并将其存储在 /target
外部(因为该目录将在构建中被覆盖!)。然后,在您的 pom.xml
中,您可以在 checkstyle 插件配置中指定此位置(请参阅: http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/custom-checker-config.html )
<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>..your version of the plugin..</version>
<configuration>
<configLocation>..your location../checkstyle-checker.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
...
</project>
关于java - 更改 Maven CheckStyle 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22094313/