You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2004/03/12 19:39:25 UTC

cvs commit: maven-components/maven-plugins/maven-compiler-plugin/src/java/org/apache/maven/plugin CompilerPlugin.java

jvanzyl     2004/03/12 10:39:25

  Modified:    maven-plugins/maven-compiler-plugin/src/java/org/apache/maven/plugin
                        CompilerPlugin.java
  Log:
  
  
  Revision  Changes    Path
  1.8       +48 -1     maven-components/maven-plugins/maven-compiler-plugin/src/java/org/apache/maven/plugin/CompilerPlugin.java
  
  Index: CompilerPlugin.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-compiler-plugin/src/java/org/apache/maven/plugin/CompilerPlugin.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CompilerPlugin.java	16 Feb 2004 20:38:15 -0000	1.7
  +++ CompilerPlugin.java	12 Mar 2004 18:39:25 -0000	1.8
  @@ -6,12 +6,21 @@
   import java.util.List;
   import java.util.Map;
   import java.util.Iterator;
  +import java.io.File;
   
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
    *
    * @version $Id$
    */
  +
  +// Conditions underwhich we fail
  +// - specified source directory does not exist
  +// - missing classpath Elements
  +// - compilation error
  +
  +// How to accurately report failures to users
  +
   public class CompilerPlugin
   {
       private Map compilers;
  @@ -24,18 +33,56 @@
   
       private String compiler;
   
  +    private boolean debug = true;
  +
       public void execute()
           throws Exception
       {
  +        if ( ! new File( sourceDirectory ).exists() )
  +        {
  +            throw new Exception( "The specified source directory '"+ sourceDirectory + "' does not exist!" );
  +        }
  +
           Compiler compiler = (Compiler) compilers.get( this.compiler );
   
           List messages = compiler.compile( classpathElements, new String[]{sourceDirectory}, outputDirectory );
   
  +        if ( debug )
  +        {
  +            for ( int i = 0; i < classpathElements.length; i++ )
  +            {
  +                String message;
  +
  +                if ( new File( classpathElements[i] ).exists() )
  +                {
  +                    message = "present in repository.";
  +                }
  +                else
  +                {
  +                    message = "Warning! not present in repository!";
  +                }
  +
  +                System.out.println( "classpathElements[ "+ i +" ] = " + classpathElements[i] + ": " + message );
  +            }
  +        }
  +
  +        boolean compilationError = false;
  +
           for ( Iterator i = messages.iterator(); i.hasNext(); )
           {
               CompilerError message = (CompilerError) i.next();
   
  +            if ( message.isError() )
  +            {
  +                compilationError = true;
  +            }
  +
               System.out.println( message.getMessage() );
  +        }
  +
  +        if ( compilationError )
  +        {
  +            throw new Exception( "Compilation failure!" );
           }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org