Preventing checkstyle from running in a specific maven submodule

JavaMavenCheckstyle

Java Problem Overview


I would like to define a checkstyle run in a pom file, and have it run on all the submodules except certain specified ones.

In other words, I need some sort of <excludes> (which exists but applies to filenames) but which targets modules. Any idea anyone?

Java Solutions


Solution 1 - Java

If you do not want to change your pom.xml you may set the skip to true from command line using the –D option. This was mentioned above as "overridden the skip parameter within an execution". This is quite similar to -Dmaven.test.skip=true usage.

mvn site -Dcheckstyle.skip=true

Solution 2 - Java

Put the following in the projects that you want checkstyle disabled for:

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

Checkstyle will still run, but will perform a no-op...

That is unless you override the default binding of maven-checkstyle-plugin's skip parameter in which case you could achieve the same effect with the following in the specific project

<project>
  ...
  <build>
    ...
    <plugins>
      ...
      <plugin>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>

Unless of course you have overridden the skip parameter within an execution... but if you know what that is you also know the solution and would not be asking this question ;-)

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
QuestionMiquelView Question on Stackoverflow
Solution 1 - JavaHaim RamanView Answer on Stackoverflow
Solution 2 - JavaStephen ConnollyView Answer on Stackoverflow