Preventing checkstyle from running in a specific maven submodule

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?


Solution 1:

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:

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 ;-)