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?
You need to specify the parameter with the right syntax:
mvn checkstyle:check -Dincludes="src/main/java/MyClass.java"
For further information: https://maven.apache.org/plugins/maven-checkstyle-plugin/check-mojo.html