mirror of https://github.com/apache/maven.git
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:
parent
1612049e44
commit
a380e3ceb0
|
@ -68,11 +68,6 @@ public class JavacCompiler
|
||||||
|
|
||||||
List args = new ArrayList( sources.length + 5 + compilerOptions.size() * 2 );
|
List args = new ArrayList( sources.length + 5 + compilerOptions.size() * 2 );
|
||||||
|
|
||||||
if ( config.isDebug() )
|
|
||||||
{
|
|
||||||
args.add( "-g" );
|
|
||||||
}
|
|
||||||
|
|
||||||
args.add( "-d" );
|
args.add( "-d" );
|
||||||
|
|
||||||
args.add( destinationDir.getAbsolutePath() );
|
args.add( destinationDir.getAbsolutePath() );
|
||||||
|
@ -83,6 +78,11 @@ public class JavacCompiler
|
||||||
|
|
||||||
args.add( getClasspathString( config.getClasspathEntries() ) );
|
args.add( getClasspathString( config.getClasspathEntries() ) );
|
||||||
|
|
||||||
|
if ( config.isDebug() )
|
||||||
|
{
|
||||||
|
args.add( "-g" );
|
||||||
|
}
|
||||||
|
|
||||||
Iterator it = compilerOptions.entrySet().iterator();
|
Iterator it = compilerOptions.entrySet().iterator();
|
||||||
|
|
||||||
while ( it.hasNext() )
|
while ( it.hasNext() )
|
||||||
|
@ -116,13 +116,14 @@ public class JavacCompiler
|
||||||
|
|
||||||
Boolean ok = (Boolean) compile.invoke( compiler, new Object[] { args.toArray( new String[0] ) } );
|
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() ) ) ) );
|
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;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,10 +148,18 @@ public class JavacCompiler
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( buffer.length() == 0 && line.startsWith( "error: " ) )
|
||||||
|
{
|
||||||
|
errors.add( new CompilerError( line ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
buffer.append( line );
|
buffer.append( line );
|
||||||
|
|
||||||
buffer.append( '\n' );
|
buffer.append( '\n' );
|
||||||
} while ( !line.endsWith( "^" ) );
|
}
|
||||||
|
}
|
||||||
|
while ( !line.endsWith( "^" ) );
|
||||||
|
|
||||||
// add the error bean
|
// add the error bean
|
||||||
errors.add( parseModernError( buffer.toString() ) );
|
errors.add( parseModernError( buffer.toString() ) );
|
||||||
|
@ -187,7 +196,7 @@ public class JavacCompiler
|
||||||
endcolumn = context.length();
|
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 )
|
catch ( NoSuchElementException nse )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue