maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r829018 - in /maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli: AbstractMavenTransferListener.java BatchModeMavenTransferListener.java ConsoleMavenTransferListener.java MavenCli.java
Date Fri, 23 Oct 2009 12:11:48 GMT
Author: bentmann
Date: Fri Oct 23 12:11:47 2009
New Revision: 829018

URL: http://svn.apache.org/viewvc?rev=829018&view=rev
Log:
o Fixed transfer listener to output to proper stream

Modified:
    maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/AbstractMavenTransferListener.java
    maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/BatchModeMavenTransferListener.java
    maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/ConsoleMavenTransferListener.java
    maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java

Modified: maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/AbstractMavenTransferListener.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/AbstractMavenTransferListener.java?rev=829018&r1=829017&r2=829018&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/AbstractMavenTransferListener.java
(original)
+++ maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/AbstractMavenTransferListener.java
Fri Oct 23 12:11:47 2009
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import java.io.PrintStream;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.util.Locale;
@@ -31,8 +32,15 @@
     implements ArtifactTransferListener
 {
 
+    protected PrintStream out;
+
     private boolean showChecksumEvents;
 
+    protected AbstractMavenTransferListener( PrintStream out )
+    {
+        this.out = ( out != null ) ? out : System.out;
+    }
+
     protected boolean showEvent( ArtifactTransferEvent event )
     {
         if ( event.getResource() == null )
@@ -70,7 +78,7 @@
         String message =
             transferEvent.getRequestType() == ArtifactTransferEvent.REQUEST_PUT ? "Uploading"
: "Downloading";
 
-        System.out.println( message + ": " + transferEvent.getResource().getUrl() );
+        out.println( message + ": " + transferEvent.getResource().getUrl() );
     }
 
     public void transferStarted( ArtifactTransferEvent transferEvent )
@@ -132,7 +140,7 @@
                 throughput = " at " + format.format( kbPerSec ) + " KB/sec";
             }
 
-            System.out.println( l + " " + type + throughput );
+            out.println( l + " " + type + throughput );
         }
     }
 

Modified: maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/BatchModeMavenTransferListener.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/BatchModeMavenTransferListener.java?rev=829018&r1=829017&r2=829018&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/BatchModeMavenTransferListener.java
(original)
+++ maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/BatchModeMavenTransferListener.java
Fri Oct 23 12:11:47 2009
@@ -19,8 +19,15 @@
  * under the License.
  */
 
-public class BatchModeMavenTransferListener
+import java.io.PrintStream;
+
+class BatchModeMavenTransferListener
     extends AbstractMavenTransferListener
 {
 
+    public BatchModeMavenTransferListener( PrintStream out )
+    {
+        super( out );
+    }
+
 }

Modified: maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/ConsoleMavenTransferListener.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/ConsoleMavenTransferListener.java?rev=829018&r1=829017&r2=829018&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/ConsoleMavenTransferListener.java
(original)
+++ maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/ConsoleMavenTransferListener.java
Fri Oct 23 12:11:47 2009
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+import java.io.PrintStream;
+
 import org.apache.maven.repository.ArtifactTransferEvent;
 
 /**
@@ -26,10 +28,15 @@
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  */
-public class ConsoleMavenTransferListener
+class ConsoleMavenTransferListener
     extends AbstractMavenTransferListener
 {
 
+    public ConsoleMavenTransferListener( PrintStream out )
+    {
+        super( out );
+    }
+
     @Override
     protected void doProgress( ArtifactTransferEvent transferEvent )
     {
@@ -39,11 +46,11 @@
         // TODO [BP]: Sys.out may no longer be appropriate, but will \r work with getLogger()?
         if ( total >= 1024 )
         {
-            System.out.print( ( complete / 1024 ) + "/" + ( total == -1 ? "?" : ( total /
1024 ) + " KB" ) + "\r" );
+            out.print( ( complete / 1024 ) + "/" + ( total == -1 ? "?" : ( total / 1024 )
+ " KB" ) + "\r" );
         }
         else
         {
-            System.out.print( complete + "/" + ( total == -1 ? "?" : total + " B" ) + "\r"
);
+            out.print( complete + "/" + ( total == -1 ? "?" : total + " B" ) + "\r" );
         }
     }
 

Modified: maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java?rev=829018&r1=829017&r2=829018&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java (original)
+++ maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java Fri
Oct 23 12:11:47 2009
@@ -343,7 +343,7 @@
             return 1;
         }
 
-        populateRequest( request, commandLine, workingDirectory, debug, quiet, showErrors
);
+        populateRequest( request, commandLine, workingDirectory, debug, quiet, showErrors,
stdout );
 
         request.setExecutionListener( new ExecutionEventLogger( logger ) );
 
@@ -602,7 +602,8 @@
     }
     
     private MavenExecutionRequest populateRequest( MavenExecutionRequest request, CommandLine
commandLine,
-                                                  String workingDirectory, boolean debug,
boolean quiet, boolean showErrors )
+                                                   String workingDirectory, boolean debug,
boolean quiet,
+                                                   boolean showErrors, PrintStream stdout
)
     {
         // ----------------------------------------------------------------------
         // Now that we have everything that we need we will fire up plexus and
@@ -729,11 +730,11 @@
 
         if ( request.isInteractiveMode() )
         {
-            transferListener = new ConsoleMavenTransferListener();
+            transferListener = new ConsoleMavenTransferListener( stdout );
         }
         else
         {
-            transferListener = new BatchModeMavenTransferListener();
+            transferListener = new BatchModeMavenTransferListener( stdout );
         }
 
         transferListener.setShowChecksumEvents( false );



Mime
View raw message