Disable maven checkstyle

独自空忆成欢 提交于 2020-02-17 05:32:05

问题


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 ?


回答1:


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.




回答2:


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>



回答3:


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>



回答4:


In one line:

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


来源:https://stackoverflow.com/questions/32308188/disable-maven-checkstyle

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!