in src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java [507:590]
private void executeJDepsCommandLine( Commandline cmd, File jOutputDirectory,
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()
{
@Override
public void consumeLine( String line )
{
if ( !line.startsWith( "Picked up JAVA_TOOL_OPTIONS:" ) )
{
super.consumeLine( line );
}
}
};
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 ( exitCode != 0 )
{
if ( StringUtils.isNotEmpty( output ) )
{
getLog().info( output );
}
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() );
}
if ( StringUtils.isNotEmpty( output ) )
{
getLog().info( output );
}
}
catch ( CommandLineException e )
{
throw new MojoExecutionException( "Unable to execute jdeps command: " + e.getMessage(), e );
}
// ----------------------------------------------------------------------
// Handle JDeps warnings
// ----------------------------------------------------------------------
if ( StringUtils.isNotEmpty( err.getOutput() ) && getLog().isWarnEnabled() )
{
getLog().warn( "JDeps Warnings" );
StringTokenizer token = new StringTokenizer( err.getOutput(), "\n" );
while ( token.hasMoreTokens() )
{
String current = token.nextToken().trim();
getLog().warn( current );
}
}
}