brett       2005/03/20 21:33:52

  Modified:    maven-mboot2/src/main/java/compile JavacCompiler.java
  Log:
  don't attempt and fail to compile when there is no sources
  
  Revision  Changes    Path
  1.5       +15 -6     
maven-components/maven-mboot2/src/main/java/compile/JavacCompiler.java
  
  Index: JavacCompiler.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-mboot2/src/main/java/compile/JavacCompiler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JavacCompiler.java        21 Mar 2005 05:26:32 -0000      1.4
  +++ JavacCompiler.java        21 Mar 2005 05:33:52 -0000      1.5
  @@ -29,6 +29,7 @@
   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 @@
   
           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 @@
   
           args.add( getClasspathString( config.getClasspathEntries() ) );
   
  -        if ( config.isDebug() )
  -        {
  -            args.add( "-g" );
  -        }
  -
           Iterator it = compilerOptions.entrySet().iterator();
   
           while ( it.hasNext() )
  @@ -109,7 +118,7 @@
   
           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() ) ) ) );
  
  
  

Reply via email to