The following examples describe the basic usage of the Checkstyle Plugin.
To generate the Checkstyle report as part of the Project Reports, add the Checkstyle Plugin in the <reporting> section of your pom.xml.
<project> ... <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> </plugin> </plugins> </reporting> ... </project>
Then, execute the site phase to generate the report.
mvn site
You can also generate the Checkstyle report by explicitly executing the checkstyle:checkstyle goal from the command line. It is not required to specify the Checkstyle Plugin in your pom.xml unless you want to use a specific configuration.
mvn checkstyle:checkstyle
To specifically configure the Checkstyle Plugin, you need to the add it in the <build> section of your pom.xml as shown in the sample below.
<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> <configuration> <enableRulesSummary>false</enableRulesSummary> ... </configuration> </plugin> </plugins> </build> ... </project>