[ http://jira.codehaus.org/browse/MOJO-1651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=258244#action_258244 ]
Jochen Wiedmann commented on MOJO-1651: --------------------------------------- Unit tests would be nice, of course! > Display All files that arent valid when running the validation mojo > ------------------------------------------------------------------- > > Key: MOJO-1651 > URL: http://jira.codehaus.org/browse/MOJO-1651 > Project: Mojo > Issue Type: Improvement > Affects Versions: xml-maven-plugin 1.0 > Reporter: Paul Reeves > Priority: Minor > Attachments: ValidateMojo_patch.txt > > > I've started to using the plugin to validate xml files during a build and > break the build if the files are not valid. > Currently the Validate mojo stops validating when it encounters a problem an > xml file and exits (it does not check any other files). > I've patched a version which takes a configuration parameter > <failOnFirstError> > This has a default value of true (which allows the plugin to behave as it > normally does) > If: > <failOnFirstError>false</failOnfirstError> is set then every parse error is > logged to the console > The plugin then aborts with a MojoExecutionException > This is handy for us as we can fix all the errors in one go rather than > running the plugin many times. > An example of pom configuration is shown below > <plugin> > <groupId>org.codehaus.mojo</groupId> > <artifactId>xml-maven-plugin</artifactId> > <version>1.0-SNAPSHOT</version> > <executions> > <execution> > <goals> > <goal>validate</goal> > </goals> > </execution> > </executions> > <configuration> > <failOnFirstError>false</failOnFirstError> > <validationSets> > <validationSet> > <dir>src/main/webapp</dir> > <includes> > <include>**/*.xhtml</include> > </includes> > </validationSet> > </validationSets> > </configuration> > </plugin> > An example of console output is shown below > .... > [INFO] [xml:validate {execution: default}] > [ERROR] While parsing C:\foo\webapp\src\main\webapp\foo\bar\aaa.xhtml, at > file:/C:/foo/webapp/src/main/webapp/foo/bar/aaa.xhtml, line 2, column 1: > Content is not allowed in prolog. > [ERROR] While parsing C:\foo\webapp\src\main\webapp\foo\bar\bbb.xhtml, at > file:/C:/foo/webapp/src/main/webapp/foo/bar/bbb.xhtml, line 2, column 1: > Content is not allowed in prolog. > [ERROR] While parsing C:\foo\webapp\src\main\webapp\foo\bar\ccc.xhtml, at > file:/C:/foo/webapp/src/main/webapp/foo/bar/ccc.xhtml, line 7, column 10: > The string "--" is not permitted within comments. > [INFO] > ------------------------------------------------------------------------ > [ERROR] BUILD ERROR > [INFO] > ------------------------------------------------------------------------ > [INFO] XML Validate failed on multiple documents, see above. > [INFO] > ------------------------------------------------------------------------ > [INFO] For more information, run Maven with the -e switch > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 10 seconds > [INFO] Finished at: Wed Mar 02 16:06:26 GMT 2011 > [INFO] Final Memory: 34M/82M > [INFO] > ------------------------------------------------------------------------ > If failOnFirstError is set to true or omitted, the plugin behaves as it did > before. > .... > Patch file included, let me know if you want unit tests > Regards > Paul -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email