maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r431618 - in /maven/sandbox/plugins/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker: FileLogger.java InvokerMojo.java
Date Tue, 15 Aug 2006 15:23:08 GMT
Author: jdcasey
Date: Tue Aug 15 08:23:07 2006
New Revision: 431618

URL: http://svn.apache.org/viewvc?rev=431618&view=rev
Log:
Adding option to stream build logs to the mojo output.

Modified:
    maven/sandbox/plugins/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/FileLogger.java
    maven/sandbox/plugins/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java

Modified: maven/sandbox/plugins/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/FileLogger.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/FileLogger.java?rev=431618&r1=431617&r2=431618&view=diff
==============================================================================
--- maven/sandbox/plugins/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/FileLogger.java
(original)
+++ maven/sandbox/plugins/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/FileLogger.java
Tue Aug 15 08:23:07 2006
@@ -1,5 +1,6 @@
 package org.apache.maven.plugin.invoker;
 
+import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.shared.invoker.InvocationOutputHandler;
 import org.codehaus.plexus.util.IOUtil;
 
@@ -15,10 +16,19 @@
     private PrintStream stream;
     
     private boolean shouldFinalize = true;
+
+    private final Log log;
     
     public FileLogger( File outputFile )
         throws IOException
     {
+        this( outputFile, null );
+    }
+    
+    public FileLogger( File outputFile, Log log )
+        throws IOException
+    {
+        this.log = log;
         stream = new PrintStream( new FileOutputStream( outputFile  ) );
         
         Runnable finalizer = new Runnable()
@@ -37,7 +47,7 @@
         
         Runtime.getRuntime().addShutdownHook( new Thread( finalizer ) );
     }
-    
+
     public PrintStream getPrintStream()
     {
         return stream;
@@ -47,10 +57,20 @@
     {
         stream.println( line );
         stream.flush();
+        
+        if ( log != null )
+        {
+            log.info( line );
+        }
     }
     
     public void close()
     {
+        if ( stream != null )
+        {
+            stream.flush();
+        }
+        
         IOUtil.close( stream );
     }
     

Modified: maven/sandbox/plugins/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java?rev=431618&r1=431617&r2=431618&view=diff
==============================================================================
--- maven/sandbox/plugins/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
(original)
+++ maven/sandbox/plugins/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
Tue Aug 15 08:23:07 2006
@@ -58,6 +58,13 @@
     extends AbstractMojo
 {
     /**
+     * Flag used to determine whether the build logs should be output to the normal mojo
log.
+     * 
+     * @parameter expression="${invoker.streamLogs}" default-value="false"
+     */
+    private boolean streamLogs;
+    
+    /**
      * The local repository for caching artifacts.
      * 
      * @parameter expression="${invoker.localRepositoryPath}"
@@ -237,7 +244,14 @@
 
                 try
                 {
-                    logger = new FileLogger( outputLog );
+                    if ( streamLogs )
+                    {
+                        logger = new FileLogger( outputLog, getLog() );
+                    }
+                    else
+                    {
+                        logger = new FileLogger( outputLog );
+                    }
                     
                     getLog().debug( "build log initialized in: " + outputLog );
                 }



Mime
View raw message