}
}
}
catch ( IOException e )
{
throw new CompilerException( "Error creating file with javac arguments", e );
}
CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
int returnCode;
List messages;
if ( ( getLogger() != null ) && getLogger().isDebugEnabled() )
{
File commandLineFile =
new File( config.getOutputLocation(), "javac." + ( Os.isFamily( Os.FAMILY_WINDOWS ) ? "bat" : "sh" ) );
try
{
FileUtils.fileWrite( commandLineFile.getAbsolutePath(), cli.toString().replaceAll( "'", "" ) );
if ( !Os.isFamily( Os.FAMILY_WINDOWS ) )
{
Runtime.getRuntime().exec( new String[]{ "chmod", "a+x", commandLineFile.getAbsolutePath() } );
}
}
catch ( IOException e )
{
if ( ( getLogger() != null ) && getLogger().isWarnEnabled() )
{
getLogger().warn( "Unable to write '" + commandLineFile.getName() + "' debug script file", e );
}
}
}
try
{
returnCode = CommandLineUtils.executeCommandLine( cli, out, err );
messages = parseModernStream( returnCode, new BufferedReader( new StringReader( err.getOutput() ) ) );
}
catch ( CommandLineException e )
{
throw new CompilerException( "Error while executing the external compiler.", e );
}
catch ( IOException e )
{
throw new CompilerException( "Error while executing the external compiler.", e );
}
if ( ( returnCode != 0 ) && messages.isEmpty() )
{
if ( err.getOutput().length() == 0 )
{
throw new CompilerException(
"Unknown error trying to execute the external compiler: " + EOL + cli.toString() );
}
else
{
messages.add( new CompilerError(