This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
2010-11-15 21:14:51 CET
Hi all, I have a little problem with configuring maven with checkstyle to generate reports. This is the pom of the project which will be added to some CIS (dont know for sure will it be cruise or hadson or bamboo...)
The problem which i am experiencing is that i have a custom checkstyle configuration , which controls the coding standards and i would like to fail the build if any type of checkstyle error has been found while cross checking it with the "checkstyle.xml". Now if the code of the project contains any type of error the build will fail since i have setted the failOnViolation/Error on true value. The xmls of the plug in are generated properly under target window, but i cant get the html report generated when there are errors. Even when i run the maven with mvn site. Can you please tell me how to get the html report generated even if the build fails because of the checkstyle?
For the record i have found a way today how to accomplish the goal i needed, this is my modified pom.xml currently
By running it through the maven in this particular sequence of the phases "clean site package" , i can generate the html reports under path $(build)\target\site and fail the build if there are any checkstyle errors before i execute the unit tests and the rest of the phases.
My question now will be, is there any way how to accomplish this , without adding another profile like the one above (secondary) that will take care for the second execution for the goal check since i cant have 2 executions of the same plug in , under the default profile?
Glad you got further - I'm afraid I don't have time to look into this further at the moment (about to catch a train to devoxx). But most projects would not fail a build outright due to checkstyle. Instead they would use something like Hudson CI to highlight the problem to developers.
Joined: Nov 15, 2010
You are correct most CI wont fail the build unless i tell them so , and thats whats my goal is , if strict coding standards are not met i would like to fail the build, the check goal will print the reason on maven console that the reason of failure is the existence of checkstyle errors and the reports will give the developer additional hint where to look for the checkstyle error. At this point i have accomplished that. But i am curious regarding some more elegant way if there is any how can this be solved as per my last comment