jdcasey     2005/04/07 22:30:12

  Modified:    
maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade
                        Tag: MAVEN-2_0-ALPHA_1-branch MarmaladeMojo.java
  Added:       .        Tag: MAVEN-2_0-ALPHA_1-branch .cvsignore
  Log:
  Enabled logging from marmalade mojos.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.6.2.1   +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.6.2.1
  diff -u -r1.6 -r1.6.2.1
  --- MarmaladeMojo.java        22 Mar 2005 06:51:59 -0000      1.6
  +++ MarmaladeMojo.java        8 Apr 2005 05:30:12 -0000       1.6.2.1
  @@ -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
  
  
  
  No                   revision
  No                   revision
  1.12.2.1  +0 -13     maven-components/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/maven-components/.cvsignore,v
  retrieving revision 1.12
  retrieving revision 1.12.2.1
  diff -u -r1.12 -r1.12.2.1
  --- .cvsignore        10 Mar 2005 21:36:57 -0000      1.12
  +++ .cvsignore        8 Apr 2005 05:30:12 -0000       1.12.2.1
  @@ -1,15 +1,2 @@
  -maven.log
  -target
   .classpath
   .project
  -bootstrap.repo
  -maven-component.i*
  -.settings
  -mboot.jar
  -dummy
  -build.ajproperties
  -.generated.lst
  -*.iml
  -*.iws
  -*.ipr
  -log.txt
  
  
  

Reply via email to