in src/main/java/org/apache/maven/plugins/jdeprscan/AbstractJDeprScanMojo.java [175:243]
private void executeJDeprScanCommandLine( Commandline cmd,
CommandLineUtils.StringStreamConsumer consumer )
throws MojoExecutionException
{
if ( getLog().isDebugEnabled() )
{
// no quoted arguments
getLog().debug( "Executing: " + CommandLineUtils.toString( cmd.getCommandline() ).replaceAll( "'", "" ) );
}
CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer out;
if ( consumer != null )
{
out = consumer;
}
else
{
out = new CommandLineUtils.StringStreamConsumer();
}
try
{
int exitCode = CommandLineUtils.executeCommandLine( cmd, out, err );
String output = ( StringUtils.isEmpty( out.getOutput() ) ? null : '\n' + out.getOutput().trim() );
if ( StringUtils.isNotEmpty( output ) )
{
getLog().info( output );
}
if ( exitCode != 0 )
{
StringBuilder msg = new StringBuilder( "\nExit code: " );
msg.append( exitCode );
if ( StringUtils.isNotEmpty( err.getOutput() ) )
{
msg.append( " - " ).append( err.getOutput() );
}
msg.append( '\n' );
msg.append( "Command line was: " ).append( cmd ).append( '\n' ).append( '\n' );
throw new MojoExecutionException( msg.toString() );
}
}
catch ( CommandLineException e )
{
throw new MojoExecutionException( "Unable to execute jdeprscan command: " + e.getMessage(), e );
}
// ----------------------------------------------------------------------
// Handle JDeprScan warnings
// ----------------------------------------------------------------------
if ( StringUtils.isNotEmpty( err.getOutput() ) && getLog().isWarnEnabled() )
{
getLog().warn( "JDeprScan Warnings" );
StringTokenizer token = new StringTokenizer( err.getOutput(), "\n" );
while ( token.hasMoreTokens() )
{
String current = token.nextToken().trim();
getLog().warn( current );
}
}
}