improve download/upload monitors

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@164024 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-04-21 10:11:08 +00:00
parent 7c947bfd53
commit c435539656
4 changed files with 29 additions and 14 deletions

View File

@ -84,7 +84,7 @@ public class DefaultWagonManager
{ {
try try
{ {
putRemoteFile( repository, source, repository.pathOf( artifact ) ); putRemoteFile( repository, source, repository.pathOf( artifact ), downloadMonitor );
} }
catch ( ArtifactPathFormatException e ) catch ( ArtifactPathFormatException e )
{ {
@ -97,7 +97,8 @@ public class DefaultWagonManager
{ {
try try
{ {
putRemoteFile( repository, source, repository.pathOfMetadata( artifactMetadata ) ); getLogger().info( "Uploading " + artifactMetadata );
putRemoteFile( repository, source, repository.pathOfMetadata( artifactMetadata ), null );
} }
catch ( ArtifactPathFormatException e ) catch ( ArtifactPathFormatException e )
{ {
@ -105,7 +106,8 @@ public class DefaultWagonManager
} }
} }
private void putRemoteFile( ArtifactRepository repository, File source, String remotePath ) private void putRemoteFile( ArtifactRepository repository, File source, String remotePath,
TransferListener downloadMonitor )
throws TransferFailedException throws TransferFailedException
{ {
Wagon wagon = null; Wagon wagon = null;
@ -118,12 +120,10 @@ public class DefaultWagonManager
throw new TransferFailedException( "Unsupported Protocol: ", e ); throw new TransferFailedException( "Unsupported Protocol: ", e );
} }
// TODO: probably don't want this on metadata... if ( downloadMonitor != null )
// TODO: not working well on upload, commented out for now {
// if ( downloadMonitor != null ) wagon.addTransferListener( downloadMonitor );
// { }
// wagon.addTransferListener( downloadMonitor );
// }
// TODO: configure these // TODO: configure these
try try
@ -227,7 +227,7 @@ public class DefaultWagonManager
throw new TransferFailedException( "Failed to determine path for artifact", e ); throw new TransferFailedException( "Failed to determine path for artifact", e );
} }
// TODO: maybe some other listener that still notifies when metadata is being retrieved? getLogger().info( "Retrieving " + metadata );
getRemoteFile( remoteRepository, destination, remotePath, null ); getRemoteFile( remoteRepository, destination, remotePath, null );
} }

View File

@ -257,4 +257,9 @@ public class SnapshotArtifactMetadata
} }
return false; return false;
} }
public String toString()
{
return "snapshot information for " + artifact.getArtifactId() + " " + artifact.getBaseVersion();
}
} }

View File

@ -106,4 +106,9 @@ public class MavenMetadata
{ {
// not used - TODO: again indicates bad design? // not used - TODO: again indicates bad design?
} }
public String toString()
{
return "project information for " + artifact.getArtifactId() + " " + artifact.getVersion();
}
} }

View File

@ -17,6 +17,7 @@ package org.apache.maven.cli;
* ==================================================================== * ====================================================================
*/ */
import org.apache.maven.wagon.WagonConstants;
import org.apache.maven.wagon.events.TransferEvent; import org.apache.maven.wagon.events.TransferEvent;
import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.events.TransferListener;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
@ -37,8 +38,10 @@ public class ConsoleDownloadMonitor
{ {
String message = transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading"; String message = transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading";
String url = transferEvent.getWagon().getRepository().getUrl();
// TODO: can't use getLogger() because this isn't currently instantiated as a component // TODO: can't use getLogger() because this isn't currently instantiated as a component
System.out.println( message + ": " + transferEvent.getResource().getName() ); System.out.println( message + ": " + url + "/" + transferEvent.getResource().getName() );
complete = 0; complete = 0;
} }
@ -53,13 +56,15 @@ public class ConsoleDownloadMonitor
long total = transferEvent.getResource().getContentLength(); long total = transferEvent.getResource().getContentLength();
complete += length; complete += length;
// TODO [BP]: Sys.out may no longer be appropriate, but will \r work with getLogger()? // TODO [BP]: Sys.out may no longer be appropriate, but will \r work with getLogger()?
System.out.print( ( complete / 1024 ) + "/" + ( total == 0 ? "?" : ( total / 1024 ) + "K" ) + "\r" ); System.out.print(
( complete / 1024 ) + "/" + ( total == WagonConstants.UNKNOWN_LENGTH ? "?" : ( total / 1024 ) + "K" ) +
"\r" );
} }
public void transferCompleted( TransferEvent transferEvent ) public void transferCompleted( TransferEvent transferEvent )
{ {
long total = transferEvent.getResource().getContentLength(); System.out.println( ( complete / 1024 ) + "K " +
System.out.println( ( total / 1024 ) + "K downloaded" ); ( transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "uploaded" : "downloaded" ) );
} }
public void transferError( TransferEvent transferEvent ) public void transferError( TransferEvent transferEvent )