Disable maven checkstyle

MavenCheckstyle

Maven Problem Overview


I want to execute a maven target but checkstyle errors forbids that. I have no time right now to correct checkstyle error (my checkstyle rules have been recently updated and I can't handle all of them right now).

Is there a way to disable checkstyle operation and execute my goal anyway ?

Maven Solutions


Solution 1 - Maven

Solution is : mvn [target] -Dcheckstyle.skip.

I like this solution as it is temporary and do not require editing of pom files, or anything that can be versioned.

Solution 2 - Maven

RandomCoders answer is the preferred one.

If you want to disable checkstyle from your pom, you can add the checkstyle plugin to the pom and set the skip flag to prevent the check.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <configuration>
        <skip>true</skip>
    </configuration>
</plugin>

Solution 3 - Maven

In one line:

    <properties>
        <checkstyle.skip>true</checkstyle.skip>
    </properties>

Solution 4 - Maven

If you want to disable checkstyle from pom, you can add checkstyle plugin to your pom and set execution phase to none. Important thing for me was that I have to set id exactly the same as in parent pom. In othercase it doesn't works.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <executions>
                <execution>
                    <id>checkstyle-validation</id>
                    <phase>none</phase>
                </execution>
            </executions>
        </plugin>

Solution 5 - Maven

The presented solutions are for the whole project/module, however I needed to have checkstyle skipped only for a certain class.
So I just want to share the solution I've found.
If you dont want to exclude the whole module and only a particular class, you can add the exclusion in the pom like following:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
                <excludes>path/to/your/class/from/sources/root/myclass.java</excludes>
            </configuration>
        </plugin>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRandomCoderView Question on Stackoverflow
Solution 1 - MavenRandomCoderView Answer on Stackoverflow
Solution 2 - MavenSven DöringView Answer on Stackoverflow
Solution 3 - MavenConstantin KonstantinidisView Answer on Stackoverflow
Solution 4 - MavenK. GolView Answer on Stackoverflow
Solution 5 - MavenFerFigView Answer on Stackoverflow