我运行了mvn checkstyle:checkstyle
,但它并没有使用我的自定义checkstyle XML文件。
请建议我如何使用自己的checkstyle文件而不是默认/当前配置的文件?
我运行了mvn checkstyle:checkstyle
,但它并没有使用我的自定义checkstyle XML文件。
请建议我如何使用自己的checkstyle文件而不是默认/当前配置的文件?
您需要在pom.xml
文件中配置文件位置:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<configLocation><!-- Specify file here --></configLocation>
</configuration>
</plugin>
</plugins>
</build>
请查看此页面以查看其他配置选项。
现在最新版本的CheckStyle已经发生了变化,您需要使用属性声明文件位置:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<properties>
<checkstyle.config.location><!-- Specify file here --></checkstyle.config.location>
</properties>
<build>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
</plugin>
</plugins>
</build>
</project>
http://blog.blundellapps.co.uk/create-your-own-checkstyle-check/
这里是源代码: