如何从 Maven Checkstyle 插件检查中排除源根目录中的文件?
How to exclude a file in the source root from Maven Checkstyle plugin checks?
我发现 Excluding classes in Maven Checkstyle plugin reports 很好地解释了如何使用
排除 类
<configuration>
<excludes>**/package/...,**/otherpackage/...</excludes>
</configuration>
但是,我似乎不知道如何在源根目录中排除像 LICENSE.txt
这样的文件。
我试过了(LICENSE.txt
和 NOTICE.txt
)
<excludes>**/LICENSE.txt,**/NOTICE.txt</excludes>
和
<excludes>LICENSE.txt,NOTICE.txt</excludes>
两者仍会针对缺少许可证发出警告 header。
我尝试将其应用到的具体项目是 Apache Commons FileUpload。
您可以尝试使用抑制过滤器:
https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/suppressions-filter.html
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<excludes>org/path/to/your/domain/*.java</excludes>
<failsOnError>true</failsOnError>
<configLocation>checkstyle.xml</configLocation>
</configuration>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
以上配置适合我。以前我在 <executions>
块中有 <configuration>
标签,这会产生不包括 类 的问题。它应该在 <executions>
标签之外。
我发现 Excluding classes in Maven Checkstyle plugin reports 很好地解释了如何使用
排除 类<configuration>
<excludes>**/package/...,**/otherpackage/...</excludes>
</configuration>
但是,我似乎不知道如何在源根目录中排除像 LICENSE.txt
这样的文件。
我试过了(LICENSE.txt
和 NOTICE.txt
)
<excludes>**/LICENSE.txt,**/NOTICE.txt</excludes>
和
<excludes>LICENSE.txt,NOTICE.txt</excludes>
两者仍会针对缺少许可证发出警告 header。
我尝试将其应用到的具体项目是 Apache Commons FileUpload。
您可以尝试使用抑制过滤器: https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/suppressions-filter.html
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<excludes>org/path/to/your/domain/*.java</excludes>
<failsOnError>true</failsOnError>
<configLocation>checkstyle.xml</configLocation>
</configuration>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
以上配置适合我。以前我在 <executions>
块中有 <configuration>
标签,这会产生不包括 类 的问题。它应该在 <executions>
标签之外。