2

在 Maven Checkstyle 插件报告中找到了排除类,它很好地解释了如何排除类

<configuration>
  <excludes>**/package/...,**/otherpackage/...</excludes>
</configuration>

但是,我似乎不知道如何排除LICENSE.txt源根目录中的文件。

我试过(对于LICENSE.txtNOTICE.txt

<excludes>**/LICENSE.txt,**/NOTICE.txt</excludes>

<excludes>LICENSE.txt,NOTICE.txt</excludes>

两者仍然会为缺少许可证标头产生警告。

我试图应用它的具体项目是Apache Commons FileUpload

4

2 回答 2

1

您可以尝试使用抑制过滤器: https ://maven.apache.org/plugins/maven-checkstyle-plugin/examples/suppressions-filter.html

于 2018-05-21T16:58:14.953 回答
1
         <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>

上面的配置对我有用。以前我在块<configuration>内有标签,<executions>它正在创建除类之外的问题。它应该在<executions>标签之外。

于 2018-12-18T14:29:20.857 回答