Create a subproject to house the resources

We'll start by adding another sub project that will house our common configuration. Let's call it build-tools. In it we put the resources that we want to include. In this example, we will add configuration files for the Checkstyle Plugin. Configuration files for other plugins, like the PMD plugin, can be included in the same subproject if you like.

Tip: put the resources into a subdirectory that you can ensure will be unique and not conflict with anyone else.

Configure the other projects to use it

Now we can include the Checkstyle configuration in the top level pom.xml.

Note: You have to specify a plugin dependency on build-tools in the <build> element of your pom.xml. It will not work inside the <reporting> element, because <reporting> does not support plugin dependencies. The rest of the configuration is done in the normal way in the <reporting> element.

Once you are done with that, ensure that you do not include the Maven Checkstyle Plugin in your sub modules, as their definition and configuration, will override the top level parent pom's definition.

Based on the Checkstyle Plugin configuration above, the values of configLocation and headerLocation will be resolved from the classpath. The build-tools JAR was included in the classpath when it was declared as a dependency to the plugin.

Lastly, kick off a build of the site.

mvn site

Every sub project will now use the same Checkstyle setup and configuration.