File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes maven with checkstyle configuration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "maven with checkstyle configuration" Watch "maven with checkstyle configuration" New topic
Author

maven with checkstyle configuration

bili san
Greenhorn

Joined: Nov 15, 2010
Posts: 3
[Avatar]
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?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Bili and welcome to Javaranch!

Can you please follow the UseCodeTags guideline and re-edit your post? We'll be able to help you out much easier that way .


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
bili san
Greenhorn

Joined: Nov 15, 2010
Posts: 3
Hi Martijn

Thank you for correcting me how to post properly

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?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Bili,

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.
bili san
Greenhorn

Joined: Nov 15, 2010
Posts: 3
Hi Martijn

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
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

"bili san", please see your private messages for an important administrative matter.


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: maven with checkstyle configuration