You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by Jerome Lacoste <je...@coffeebreaks.org> on 2004/06/17 18:50:33 UTC

Re: cvs commit: maven-components/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin CompilerMojo.java TestCompilerMojo.java

On Mon, 2004-06-14 at 17:04, jvanzyl@apache.org wrote:
> jvanzyl     2004/06/14 08:04:57
> 
>   Added:       maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin
>                         CompilerMojo.java TestCompilerMojo.java
>   Log:
>   
>   
>   Revision  Changes    Path
>   1.1                  maven-components/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java
>   
>   Index: CompilerMojo.java
>   ===================================================================
>   package org.apache.maven.plugin;
>   
>   import org.codehaus.plexus.compiler.Compiler;
>   import org.codehaus.plexus.compiler.CompilerError;
>   import org.codehaus.plexus.compiler.javac.JavacCompiler;
>   
>   import java.io.File;
>   import java.util.Iterator;
>   import java.util.List;
>   
>   /**
>    * @goal compile
>    *
>    * @description Compiles application sources
>    *
>    * @parameter
>    *  name="sourceDirectory"
>    *  type="String"
>    *  required="true"
>    *  validator=""
>    *  expression="#project.build.sourceDirectory"
>    *  description=""
>    * @parameter
>    *  name="outputDirectory"
>    *  type="String"
>    *  required="true"
>    *  validator=""
>    *  expression="#project.build.directory/classes"
>    *  description=""
>    * @parameter
>    *  name="classpathElements"
>    *  type="String[]"
>    *  required="true"
>    *  validator=""
>    *  expression="#project.classpathElements"
>    *  description=""
>    *
>    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
>    * @version $Id: CompilerMojo.java,v 1.1 2004/06/14 15:04:57 jvanzyl Exp $
>    * @todo use compile source roots and not the pom.build.sourceDirectory so that any
>    *       sort of preprocessing and/or source generation can be taken into consideration.
>    */
>   
>   public class CompilerMojo
>       extends AbstractPlugin
>   {
>       private Compiler compiler = new JavacCompiler();
>   
>       private boolean debug = false;
>   
>       public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
>           throws Exception
>       {
>           // ----------------------------------------------------------------------
>           //
>           // ----------------------------------------------------------------------
>   
>           String sourceDirectory = (String) request.getParameter( "sourceDirectory" );
>   
>           String outputDirectory = (String) request.getParameter( "outputDirectory" );
>   
>           String[] classpathElements = (String[]) request.getParameter( "classpathElements" );
>   
>           String compilerId = (String) request.getParameter( "compiler" );
>   
>           // ----------------------------------------------------------------------
>           //
>           // ----------------------------------------------------------------------
>           
>           if ( ! new File( sourceDirectory ).exists() )
>           {
>               return;
>           }
>   
>           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 );


what is the status on login? Is System.out to be the preferred mecanism?
Or will a logging framework be involved at some point?

Jerome