mirror of https://github.com/apache/maven.git
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:
parent
7c947bfd53
commit
c435539656
|
@ -84,7 +84,7 @@ public class DefaultWagonManager
|
|||
{
|
||||
try
|
||||
{
|
||||
putRemoteFile( repository, source, repository.pathOf( artifact ) );
|
||||
putRemoteFile( repository, source, repository.pathOf( artifact ), downloadMonitor );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
|
@ -97,7 +97,8 @@ public class DefaultWagonManager
|
|||
{
|
||||
try
|
||||
{
|
||||
putRemoteFile( repository, source, repository.pathOfMetadata( artifactMetadata ) );
|
||||
getLogger().info( "Uploading " + artifactMetadata );
|
||||
putRemoteFile( repository, source, repository.pathOfMetadata( artifactMetadata ), null );
|
||||
}
|
||||
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
|
||||
{
|
||||
Wagon wagon = null;
|
||||
|
@ -118,12 +120,10 @@ public class DefaultWagonManager
|
|||
throw new TransferFailedException( "Unsupported Protocol: ", e );
|
||||
}
|
||||
|
||||
// TODO: probably don't want this on metadata...
|
||||
// TODO: not working well on upload, commented out for now
|
||||
// if ( downloadMonitor != null )
|
||||
// {
|
||||
// wagon.addTransferListener( downloadMonitor );
|
||||
// }
|
||||
if ( downloadMonitor != null )
|
||||
{
|
||||
wagon.addTransferListener( downloadMonitor );
|
||||
}
|
||||
|
||||
// TODO: configure these
|
||||
try
|
||||
|
@ -227,7 +227,7 @@ public class DefaultWagonManager
|
|||
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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -257,4 +257,9 @@ public class SnapshotArtifactMetadata
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "snapshot information for " + artifact.getArtifactId() + " " + artifact.getBaseVersion();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,4 +106,9 @@ public class MavenMetadata
|
|||
{
|
||||
// not used - TODO: again indicates bad design?
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "project information for " + artifact.getArtifactId() + " " + artifact.getVersion();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.TransferListener;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
@ -37,8 +38,10 @@ public class ConsoleDownloadMonitor
|
|||
{
|
||||
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
|
||||
System.out.println( message + ": " + transferEvent.getResource().getName() );
|
||||
System.out.println( message + ": " + url + "/" + transferEvent.getResource().getName() );
|
||||
|
||||
complete = 0;
|
||||
}
|
||||
|
@ -53,13 +56,15 @@ public class ConsoleDownloadMonitor
|
|||
long total = transferEvent.getResource().getContentLength();
|
||||
complete += length;
|
||||
// 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 )
|
||||
{
|
||||
long total = transferEvent.getResource().getContentLength();
|
||||
System.out.println( ( total / 1024 ) + "K downloaded" );
|
||||
System.out.println( ( complete / 1024 ) + "K " +
|
||||
( transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "uploaded" : "downloaded" ) );
|
||||
}
|
||||
|
||||
public void transferError( TransferEvent transferEvent )
|
||||
|
|
Loading…
Reference in New Issue