I want build to fail if 'checkstyle' detects any error. I referred to how to stop maven build using checkstyle and https://maven.apache.org/plugins/maven-checkstyle-plugin/usage.html. My pom.xml looks like this:
<build>
<pluginManagement>
<plugins>
.....
.....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.11</version>
<executions>
<execution>
<id>validate</id>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
<configuration>
<configLocation>config/sun_checks.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Running checkstyle:check reports the errors in source. But running install succeeds. I have tried binding the plugin to validate, process-sources and other phases. But build succeeds all the time. Am I missing some configuration?