I have a parent POM with this checkstyle configuration:
<properties>
<checkstyle.configLocation>src/checkstyle/checkstyle.xml</checkstyle.configLocation>
<checkstyle.suppressionsLocation>src/checkstyle/checkstyle-suppressions.xml</checkstyle.suppressionsLocation>
<maven-checkstyle-plugin.version>2.17</maven-checkstyle-plugin.version>
<properties>
<build>
<pluginManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>${checkstyle.configLocation}</configLocation>
<suppressionsLocation>${checkstyle.suppressionsLocation}</suppressionsLocation>
</configuration>
</execution>
</executions>
</plugin>
</pluginManagement>
</build>
And this is the inherited POM:
<build>
<plugins>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>${project.parent.basedir}/${checkstyle.configLocation}</configLocation>
<suppressionsFile>${project.parent.basedir}/${checkstyle.suppressionsLocation}</suppressionsFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
I want to execute the checkstyle only in the inherited projects (because I will have multiple projects that use the parent pom). In parent project the checkstyle is not necessary to run but I have to use the checkstyle.xml and checkstyle-suppressions.xml configuration files on the parent project and use those files from inherited projects.
This is the error obtained after mvn clean install:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (validate) on project MyProject: Failed during checkstyle execution: Unable to find suppressions file at location: src/checkstyle/checkstyle-suppressions.xml: Could not find resource 'src/checkstyle/checkstyle-suppressions.xml'. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
The child project doesn't find the checkstyle configuration files from parent project.