maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-mboot2/src/main/java/compile JavacCompiler.java
Date Mon, 21 Mar 2005 06:06:42 GMT
brett       2005/03/20 22:06:42

  Modified:    maven-mboot2/src/main/java/compile JavacCompiler.java
  Log:
  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
  
  Revision  Changes    Path
  1.6       +23 -14    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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JavacCompiler.java	21 Mar 2005 05:33:52 -0000	1.5
  +++ JavacCompiler.java	21 Mar 2005 06:06:42 -0000	1.6
  @@ -68,11 +68,6 @@
   
           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 @@
   
           args.add( getClasspathString( config.getClasspathEntries() ) );
   
  +        if ( config.isDebug() )
  +        {
  +            args.add( "-g" );
  +        }
  +
           Iterator it = compilerOptions.entrySet().iterator();
   
           while ( it.hasNext() )
  @@ -116,13 +116,14 @@
   
           Boolean ok = (Boolean) compile.invoke( compiler, new Object[] { args.toArray( new
String[0] ) } );
   
  -        if ( !ok.booleanValue() )
  +        List messages = parseModernStream( new BufferedReader( new InputStreamReader( new
ByteArrayInputStream( err.toByteArray() ) ) ) );
  +
  +        if ( !ok.booleanValue() && messages.isEmpty() )
           {
  -            throw new Exception( "Failure executing javac: \n\n'javac " + args + "'\n\n"
+ err.toString() );
  +            // TODO: don't throw exception
  +            throw new Exception( "Failure executing javac, but could not parse the error:\n\n"
+ err.toString() );
           }
   
  -        List messages = parseModernStream( new BufferedReader( new InputStreamReader( new
ByteArrayInputStream( err.toByteArray() ) ) ) );
  -
           return messages;
       }
   
  @@ -147,10 +148,18 @@
                       return errors;
                   }
   
  -                buffer.append( line );
  +                if ( buffer.length() == 0 && line.startsWith( "error: " ) )
  +                {
  +                    errors.add( new CompilerError( line ) );
  +                }
  +                else
  +                {
  +                    buffer.append( line );
   
  -                buffer.append( '\n' );
  -            } while ( !line.endsWith( "^" ) );
  +                    buffer.append( '\n' );
  +                }
  +            }
  +            while ( !line.endsWith( "^" ) );
   
               // add the error bean
               errors.add( parseModernError( buffer.toString() ) );
  @@ -187,7 +196,7 @@
                   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 )
           {
  @@ -203,4 +212,4 @@
       {
           return "Sun Javac Compiler";
       }
  -}
  +}
  \ No newline at end of file
  
  
  

Mime
View raw message