no need to throw an exception every time there is a compiler error, however make sure to process lines starting with "error: " as a compile error

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163633 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-03-21 06:06:42 +00:00
parent 1612049e44
commit a380e3ceb0
1 changed files with 24 additions and 15 deletions

View File

@ -68,11 +68,6 @@ public class JavacCompiler
List args = new ArrayList( sources.length + 5 + compilerOptions.size() * 2 );
if ( config.isDebug() )
{
args.add( "-g" );
}
args.add( "-d" );
args.add( destinationDir.getAbsolutePath() );
@ -83,6 +78,11 @@ public class JavacCompiler
args.add( getClasspathString( config.getClasspathEntries() ) );
if ( config.isDebug() )
{
args.add( "-g" );
}
Iterator it = compilerOptions.entrySet().iterator();
while ( it.hasNext() )
@ -116,13 +116,14 @@ public class JavacCompiler
Boolean ok = (Boolean) compile.invoke( compiler, new Object[] { args.toArray( new String[0] ) } );
if ( !ok.booleanValue() )
{
throw new Exception( "Failure executing javac: \n\n'javac " + args + "'\n\n" + err.toString() );
}
List messages = parseModernStream( new BufferedReader( new InputStreamReader( new ByteArrayInputStream( err.toByteArray() ) ) ) );
if ( !ok.booleanValue() && messages.isEmpty() )
{
// TODO: don't throw exception
throw new Exception( "Failure executing javac, but could not parse the error:\n\n" + err.toString() );
}
return messages;
}
@ -147,10 +148,18 @@ public class JavacCompiler
return errors;
}
if ( buffer.length() == 0 && line.startsWith( "error: " ) )
{
errors.add( new CompilerError( line ) );
}
else
{
buffer.append( line );
buffer.append( '\n' );
} while ( !line.endsWith( "^" ) );
}
}
while ( !line.endsWith( "^" ) );
// add the error bean
errors.add( parseModernError( buffer.toString() ) );
@ -187,7 +196,7 @@ public class JavacCompiler
endcolumn = context.length();
}
return new CompilerError( file, false, line, startcolumn, line, endcolumn, message );
return new CompilerError( file, true, line, startcolumn, line, endcolumn, message );
}
catch ( NoSuchElementException nse )
{