Usage

The following examples describe the basic usage of the Checkstyle Plugin.

Generate Checkstyle Report As Part of the Project Reports

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.10</version>
      </plugin>
    </plugins>
  </reporting>
  ...
</project>

Then, execute the site phase to generate the report.

mvn site

Generate Checkstyle Report As Standalone

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

Configure the Checkstyle Plugin

Maven 3

As per Maven 3 Compatibility Notes to 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.10</version>
        <configuration>
          <enableRulesSummary>false</enableRulesSummary>
           ...
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>

Maven 2

You may need to duplicate some configuration details between the <build> section and the <reporting> section, depending on whether you use maven-checkstyle-plugin as part of the build, part of site, or both.