logo Apache Maven Checkstyle Plugin

Generates a report on violations of code style and optionally fails the build if violations are detected.

homepage: maven.apache.org/plugins
fresh index:
last release: 12 months ago, first release: 2 decades ago
packaging: maven-plugin
get this artifact from: smartics central
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
checkstyle:check (phase: verify)

Performs Checkstyle analysis and outputs violations or a count of violations to the console, potentially failing the build. It can also be configured to re-use an earlier analysis.

checkstyle:checkstyle

A reporting task that performs Checkstyle analysis and generates an HTML report on any violations that Checkstyle finds.

checkstyle:checkstyle-aggregate

A reporting task that performs Checkstyle analysis and generates an aggregate HTML report on the violations that Checkstyle finds in a multi-module reactor build.

checkstyle:help

Display help information on maven-checkstyle-plugin. Call mvn checkstyle:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

Often used code snippets:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <configuration>
    <skip>true</skip>
  </configuration>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <version>2.17</version>
  <executions>
    <execution>
      <id>validate</id>
      <phase>validate</phase>
      <configuration>
        <configLocation>checkstyle.xml</configLocation>
        <encoding>UTF-8</encoding>
        <consoleOutput>true</consoleOutput>
        <failsOnError>true</failsOnError>
        <includeTestSourceDirectory>true</includeTestSourceDirectory>
      </configuration>
      <goals>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <executions>
    <execution>
      <id>validate</id>
      <phase>validate</phase>
      <configuration>
        <configLocation>
                                https://raw.githubusercontent.com/wso2/code-quality-tools/master/checkstyle/checkstyle.xml
                            </configLocation>
        <suppressionsLocation>
                                https://raw.githubusercontent.com/wso2/code-quality-tools/master/checkstyle/suppressions.xml
                            </suppressionsLocation>
        <encoding>UTF-8</encoding>
        <consoleOutput>true</consoleOutput>
        <failsOnError>true</failsOnError>
        <includeTestSourceDirectory>true</includeTestSourceDirectory>
        <excludes>**/gen/**/*</excludes>
        <skip>true</skip>
      </configuration>
      <goals>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <configuration>
    <excludes>org/wso2/carbon/apimgt/hybrid/gateway/throttling/synchronizer/dto/*,
                        org/wso2/carbon/apimgt/hybrid/gateway/throttling/synchronizer/util/mapping/throttling/*
                    </excludes>
  </configuration>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <version>${maven.checkstyleplugin.version}</version>
  <configuration>
    <excludes>
      <exclude>org/wso2/carbon/apimgt/hybrid/gateway/api/synchronizer/dto/*</exclude>
    </excludes>
  </configuration>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.