可以定义自定义Checker 配置 xml 文件,然后通过 URL、文件或构建类路径资源引用进行引用。
要引用自定义 Checkstyle Checker 配置,请使用configLocation参数。
<project> ... <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.4</version> <configuration> <configLocation>checkstyle.xml</configLocation> </configuration> </plugin> </plugins> </reporting> ... </project>
此示例使 Checkstyle 插件在依赖项或构建扩展类路径的编译范围内检查名为checkstyle.xml的文件或名为checkstyle.xml的资源。
Checkstyle 插件附带 4 个预定义的 Checkstyle 配置定义,默认选择 Sun Microsystems 定义。