Is there a possibility to somehow force maven to fail the build if there are some checkstyle
errors? Now I have to run site
goal to generate javadocs
and checkstyle
reports. I want to make it on install
goal and if checkstyle has some error I need build to fail. Is this possible to achieve?
Now I have my checkstyle
in reporting block of maven:
<reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> <configuration> <configLocation>src/test/resources/checkstyle.xml</configLocation> </configuration> </plugin> </plugins> </reporting>
It will also generate the violation report for the project which is available as a view in Eclipse. To view to violation report, go to Window -> Show View -> Other, and search for Checkstyle. Options for Violations and Violations Chart should be displayed.
You need to bind checkstyle:check
to a Maven lifecycle phase (e.g. validate ) and set failOnViolation
to true.
Something like:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> <executions> <execution> <id>checkstyle</id> <phase>validate</phase> <goals> <goal>check</goal> </goals> <configuration> <failOnViolation>true</failOnViolation> </configuration> </execution> </executions> </plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With