2

I found Excluding classes in Maven Checkstyle plugin reports which explains well how to exclude classes with

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

However, I don't seem to get how to exclude a file like LICENSE.txt in the source root.

I tried (for LICENSE.txt and NOTICE.txt)

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

and

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

which both still produce a warning for a missing license header.

The concrete project I'm trying to apply this on is Apache Commons FileUpload.

Kalle Richter
  • 8,008
  • 26
  • 77
  • 177

2 Answers2

1

You can try using Surppressions Filter: https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/suppressions-filter.html

Amila
  • 5,195
  • 1
  • 27
  • 46
  • @KarlRichter did you ever get that `` tag to work? I have the same issues right now and tried almost all the possible combination of the url. Can't seem to get it working – Gurkha Dec 18 '18 at 02:53
  • @Gurkha No, I'm sticking with suppressions-filter for some time. – Kalle Richter Dec 18 '18 at 12:15
  • @KarlRichter I got it to work, posted answer below for future references. – Gurkha Dec 18 '18 at 14:31
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>

The Above configuration works for me. Previously I had <configuration> tag inside <executions> block which was creating issues excluding the classes. It should be outside of <executions> tag.

Gurkha
  • 1,104
  • 4
  • 20
  • 37