in src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java [428:493]
private String applyPatches( Map patchesApplied )
throws MojoExecutionException
{
final StringWriter outputWriter = new StringWriter();
StreamConsumer consumer = new StreamConsumer()
{
public void consumeLine( String line )
{
if ( getLog().isDebugEnabled() )
{
getLog().debug( line );
}
outputWriter.write( line + "\n" );
}
};
// used if failFast is false
List failedPatches = new ArrayList();
for ( Object o : patchesApplied.entrySet() )
{
Entry entry = (Entry) o;
String patchName = (String) entry.getKey();
Commandline cli = (Commandline) entry.getValue();
try
{
getLog().info( "Applying patch: " + patchName );
int result = executeCommandLine( cli, consumer, consumer );
if ( result != 0 )
{
if ( failFast )
{
throw new MojoExecutionException( "Patch command failed with exit code " + result + " for "
+ patchName + ". Please see console and debug output for more information." );
}
else
{
failedPatches.add( patchName );
}
}
}
catch ( CommandLineException e )
{
throw new MojoExecutionException( "Failed to apply patch: " + patchName
+ ". See debug output for more information.", e );
}
}
if ( !failedPatches.isEmpty() )
{
getLog().error( "Failed applying one or more patches:" );
for ( Object failedPatche : failedPatches )
{
getLog().error( "* " + failedPatche );
}
throw new MojoExecutionException( "Patch command failed for one or more patches."
+ " Please see console and debug output for more information." );
}
return outputWriter.toString();
}