maven 配置checkstyle
maven settings.xml 配置
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.20</version>
</dependency>
</dependencies>
<executions>
<execution>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<skip>false</skip>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
checkstyle模板
https://github.com/checkstyle/checkstyle/tree/master/src/main/resources
可修改 severity 为 error,当编译违反规范的时候阻止编译打包
<property name="severity" value="error"/>
本文介绍如何使用Maven配置Checkstyle进行代码风格检查。通过设置maven-checkstyle-plugin插件,可以实现对Java项目的编码规范进行检查,并在构建过程中根据预设规则决定是否允许编译继续。提供了详细的settings.xml配置示例。
4607

被折叠的 条评论
为什么被折叠?



