maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject cvs commit: maven-components/maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade MarmaladeMojo.java
Date Fri, 08 Apr 2005 05:36:37 GMT
jdcasey     2005/04/07 22:36:37

  Modified:    maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade
                        MarmaladeMojo.java
  Log:
  merging changes from 1.0-alpha-1 branch that enable output to logs from a marmalade mojo.
  
  Revision  Changes    Path
  1.7       +28 -3     maven-components/maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade/MarmaladeMojo.java
  
  Index: MarmaladeMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade/MarmaladeMojo.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MarmaladeMojo.java	22 Mar 2005 06:51:59 -0000	1.6
  +++ MarmaladeMojo.java	8 Apr 2005 05:36:37 -0000	1.7
  @@ -16,6 +16,7 @@
    * limitations under the License.
    */
   
  +import org.apache.maven.monitor.logging.Log;
   import org.apache.maven.plugin.AbstractPlugin;
   import org.apache.maven.plugin.FailureResponse;
   import org.apache.maven.plugin.PluginExecutionRequest;
  @@ -25,6 +26,9 @@
   import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
   import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
   
  +import java.io.PrintWriter;
  +import java.io.StringWriter;
  +
   /**
    * @author jdcasey
    */
  @@ -47,15 +51,36 @@
   
           context.setVariable( MarmaladeMojoExecutionDirectives.REQUEST_INVAR, request );
           context.setVariable( MarmaladeMojoExecutionDirectives.RESPONSE_INVAR, response
);
  -
  +        
  +        StringWriter sOutWriter = new StringWriter();
  +        PrintWriter outWriter = new PrintWriter(sOutWriter);
  +        
  +        context.setOutWriter(outWriter);
  +        
  +        StringWriter sErrWriter = new StringWriter();
  +        PrintWriter errWriter = new PrintWriter(sErrWriter);
  +        
  +        context.setErrWriter(errWriter);
  +        
           try
           {
               script.execute( context );
           }
           catch ( MarmaladeExecutionException e )
           {
  -            FailureResponse failure = new MarmaladeMojoFailureResponse( script.getLocation(),
e );
  -            response.setExecutionFailure( failure );
  +            throw e;
  +        }
  +        
  +        StringBuffer output = sOutWriter.getBuffer();
  +        if(output.length() > 0)
  +        {
  +            getLog().info(output);
  +        }
  +        
  +        StringBuffer error = sErrWriter.getBuffer();
  +        if(error.length() > 0)
  +        {
  +            getLog().error(error);
           }
   
           // TODO: need to be able to pass back results
  
  
  

Mime
View raw message