53

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?

b4hand
  • 9,550
  • 4
  • 44
  • 49
Miquel
  • 15,405
  • 8
  • 54
  • 87

2 Answers2

119

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
Haim Raman
  • 11,508
  • 6
  • 44
  • 70
74

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

Stephen Connolly
  • 13,872
  • 6
  • 41
  • 63
  • Thanks a bunch, I had totally missed the skip option! Side note, non-important to future visitors: my real problem is the one you answered [here](http://stackoverflow.com/questions/13430904/duplicate-checkstyle-warnings-in-a-jenkins-maven-multimodule-job) and unfortunately this won't help me there :/ – Miquel Nov 17 '12 at 22:07