You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/12/20 09:35:49 UTC
[maven-invoker-plugin] 07/24: Adding option to stream build logs to
the mojo output.
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to annotated tag maven-invoker-plugin-1.0
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git
commit c9d8e23ae6941bfbc14ec7229d2fee1b83dd2e5a
Author: John Dennis Casey <jd...@apache.org>
AuthorDate: Tue Aug 15 15:23:07 2006 +0000
Adding option to stream build logs to the mojo output.
git-svn-id: https://svn.apache.org/repos/asf/maven/sandbox/plugins/maven-invoker-plugin@431618 13f79535-47bb-0310-9956-ffa450edef68
---
.../apache/maven/plugin/invoker/FileLogger.java | 22 +++++++++++++++++++++-
.../apache/maven/plugin/invoker/InvokerMojo.java | 16 +++++++++++++++-
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugin/invoker/FileLogger.java b/src/main/java/org/apache/maven/plugin/invoker/FileLogger.java
index 40ae2f4..aa944f9 100644
--- a/src/main/java/org/apache/maven/plugin/invoker/FileLogger.java
+++ b/src/main/java/org/apache/maven/plugin/invoker/FileLogger.java
@@ -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 @@ public class FileLogger
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 @@ public class FileLogger
Runtime.getRuntime().addShutdownHook( new Thread( finalizer ) );
}
-
+
public PrintStream getPrintStream()
{
return stream;
@@ -47,10 +57,20 @@ public class FileLogger
{
stream.println( line );
stream.flush();
+
+ if ( log != null )
+ {
+ log.info( line );
+ }
}
public void close()
{
+ if ( stream != null )
+ {
+ stream.flush();
+ }
+
IOUtil.close( stream );
}
diff --git a/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java b/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
index 8b5b288..b5d7e5e 100644
--- a/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
@@ -58,6 +58,13 @@ public class InvokerMojo
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 @@ public class InvokerMojo
try
{
- logger = new FileLogger( outputLog );
+ if ( streamLogs )
+ {
+ logger = new FileLogger( outputLog, getLog() );
+ }
+ else
+ {
+ logger = new FileLogger( outputLog );
+ }
getLog().debug( "build log initialized in: " + outputLog );
}
--
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.