don't attempt and fail to compile when there is no sources

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

View File

@ -29,6 +29,7 @@ import java.io.OutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -55,10 +56,23 @@ public class JavacCompiler
String[] sources = getSourceFiles( config );
if ( sources.length == 0 )
{
return Collections.EMPTY_LIST;
}
System.out.println( "Compiling " + sources.length + " source file" + ( sources.length == 1 ? "" : "s" )
+ " to " + destinationDir.getAbsolutePath() );
Map compilerOptions = config.getCompilerOptions();
List args = new ArrayList( sources.length + 5 + compilerOptions.size() * 2 );
if ( config.isDebug() )
{
args.add( "-g" );
}
args.add( "-d" );
args.add( destinationDir.getAbsolutePath() );
@ -69,11 +83,6 @@ public class JavacCompiler
args.add( getClasspathString( config.getClasspathEntries() ) );
if ( config.isDebug() )
{
args.add( "-g" );
}
Iterator it = compilerOptions.entrySet().iterator();
while ( it.hasNext() )
@ -109,7 +118,7 @@ public class JavacCompiler
if ( !ok.booleanValue() )
{
throw new Exception( "Failure executing javac: \n\t" + err.toString() );
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() ) ) ) );