Author: jmcconnell Date: Fri Jun 22 14:58:51 2007 New Revision: 549967 URL: http://svn.apache.org/viewvc?view=rev&rev=549967 Log: added failFast option (true by default), setting to false lets you process all patches and get output on all that failed
Modified: maven/sandbox/trunk/plugins/maven-patch-plugin/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java Modified: maven/sandbox/trunk/plugins/maven-patch-plugin/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-patch-plugin/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java?view=diff&rev=549967&r1=549966&r2=549967 ============================================================================== --- maven/sandbox/trunk/plugins/maven-patch-plugin/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java (original) +++ maven/sandbox/trunk/plugins/maven-patch-plugin/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java Fri Jun 22 14:58:51 2007 @@ -132,6 +132,13 @@ private File targetDirectory; /** + * true if the desired behavior is to fail the build on the first failed patch detected + * + * @parameter default-value="true" + */ + private boolean failFast; + + /** * setting natural order processing to true will all patches in a directory to be processed in an natural order * alleviating the need to declare patches directly in the project file. * @@ -408,6 +415,9 @@ } }; + // used if failFast is false + String failedPatches = null; + for ( Iterator it = patchesApplied.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Entry) it.next(); @@ -421,7 +431,18 @@ if ( result != 0 ) { - throw new MojoExecutionException( "Patch command failed (exit value != 0) for " + patchName + ". Please see debug output for more information." ); + if ( failFast ) + { + throw new MojoExecutionException( "Patch command failed (exit value != 0) for " + patchName + ". Please see debug output for more information." ); + } + else + { + if ( failedPatches == null ) + { + failedPatches = new String(); + } + failedPatches = failedPatches + patchName + "\n"; + } } } catch ( CommandLineException e ) @@ -429,6 +450,13 @@ throw new MojoExecutionException( "Failed to apply patch: " + patchName + ". See debug output for more information.", e ); } + } + + if ( failedPatches != null ) + { + getLog().info( "Failed applying one or more patches:" ); + getLog().info( failedPatches ); + throw new MojoExecutionException( "Patch command failed for one or more patches. Please see console and debug output for more information." ); } return outputWriter.toString();