Background
I have a Maven project with Checkstyle.
I run mvn checkstyle:check
to run Checkstyle against all project files.
I want to run it against a specific file.
As an example, I want to run it against src/main/java/MyClass.java
.
The following works:
mvn checkstyle:check -Dcheckstyle.includes="**\/MyClass.java"
But if I had any other classes with the same name elsewhere in the codebase, it would also check those. This is unfortunate.
The following does NOT work:
mvn checkstyle:check -Dcheckstyle.includes="src/main/java/MyClass.java"
It simply succeeds, telling me I have 0 errors. And for the record, it has errors. So it's clearly not checking that file.
Question
How can I adjust this command to run Checkstyle against a specific file given by its path, without using wildcards?
I am visiting this question after a couple of years so here is what I did to make it work:
mvn checkstyle:check -Dcheckstyle.includes="**\/Foo.java"
As mentioned in the previous answer, you can refer to the documentation for more details.
Here is what you need to know about the property checkstyle.includes
:
Specifies the names filter of the source files to be used for Checkstyle.
Type: java.lang.String
Required: Yes
User Property: checkstyle.includes
Default: **\/*.java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With