mirror of https://github.com/apache/maven.git
o Fixed transfer listener to output to proper stream
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@829018 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fce4db9c9c
commit
46584fbf1e
|
@ -19,6 +19,7 @@ package org.apache.maven.cli;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Locale;
|
||||
|
@ -31,8 +32,15 @@ public abstract class AbstractMavenTransferListener
|
|||
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 @@ public abstract class AbstractMavenTransferListener
|
|||
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 @@ public abstract class AbstractMavenTransferListener
|
|||
throughput = " at " + format.format( kbPerSec ) + " KB/sec";
|
||||
}
|
||||
|
||||
System.out.println( l + " " + type + throughput );
|
||||
out.println( l + " " + type + throughput );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,15 @@ package org.apache.maven.cli;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
public class BatchModeMavenTransferListener
|
||||
import java.io.PrintStream;
|
||||
|
||||
class BatchModeMavenTransferListener
|
||||
extends AbstractMavenTransferListener
|
||||
{
|
||||
|
||||
public BatchModeMavenTransferListener( PrintStream out )
|
||||
{
|
||||
super( out );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.maven.cli;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
import org.apache.maven.repository.ArtifactTransferEvent;
|
||||
|
||||
/**
|
||||
|
@ -26,10 +28,15 @@ import org.apache.maven.repository.ArtifactTransferEvent;
|
|||
*
|
||||
* @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 @@ public class ConsoleMavenTransferListener
|
|||
// 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" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ public class MavenCli
|
|||
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 @@ public class MavenCli
|
|||
}
|
||||
|
||||
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 @@ public class MavenCli
|
|||
|
||||
if ( request.isInteractiveMode() )
|
||||
{
|
||||
transferListener = new ConsoleMavenTransferListener();
|
||||
transferListener = new ConsoleMavenTransferListener( stdout );
|
||||
}
|
||||
else
|
||||
{
|
||||
transferListener = new BatchModeMavenTransferListener();
|
||||
transferListener = new BatchModeMavenTransferListener( stdout );
|
||||
}
|
||||
|
||||
transferListener.setShowChecksumEvents( false );
|
||||
|
|
Loading…
Reference in New Issue