How to use the maven checkstyle plugin in a multi-module project?

This is my parent pom.xml(part of it) in a multi-module project:

...
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

This configuration instructs mvnto execute the plugin checkstylein the root project and each submodule. I do not want it to work that way. Instead, I want this plugin to be executed only for the root project and skipped for each submodule. At the same time, I have many submodules, and I do not like the idea of ​​explicitly skipping the execution of the plugin in each of them.

checkstyle "... , Maven Checkstyle ..". , pom.xml? , , .

+5
2

, 2 : pom. pom pom.

, .

checkstyle aggregator/root pom. , .


<relativePath> <parent>

, .
http://sourceforge.net/projects/hibernate/files/hibernate3

, - ,

project-root
   |
   +-pom.xml
   |
   + parent
   |  |
   |  +-pom.xml
   |
   + core
      |
      +-pom.xml

   .. rest is scipped for brevity

project-root/pom.xml

<parent>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-parent</artifactId>
    <version>3.5.4-Final</version>
    <relativePath>parent/pom.xml</relativePath>
</parent>

<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<packaging>pom</packaging>

<name>Hibernate Core Aggregator</name>
<description>Aggregator of the Hibernate Core modules.</description>

<modules>
    <module>parent</module>
    <module>core</module>

project-root/parent/pom.xml

<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
<packaging>pom</packaging>
<version>3.5.4-Final</version>

project-root/core/pom.xml

<parent>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-parent</artifactId>
    <version>3.5.4-Final</version>
    <relativePath>../parent/pom.xml</relativePath>
</parent>

<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<packaging>jar</packaging>
+2

, root pom.xml?

, <inherited> <plugin>. POM:

: true false, POM, .

- :

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <!-- Lock down plugin version for build reproducibility -->
  <version>2.5</version>
  <inherited>true</inherited>
  <configuration>
    ...
  </configuration>
</plugin> 

/ ( ):

+4

All Articles