maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From schu...@apache.org
Subject maven git commit: [MNG-5457] Show repository id when downloading or uploading from/to a remote repository
Date Sun, 18 Dec 2016 03:28:14 GMT
Repository: maven
Updated Branches:
  refs/heads/master 286c7ffba -> ff5d215b5


[MNG-5457] Show repository id when downloading or uploading from/to a remote repository

This reverts commit 2385484a813edc157ba151c9daa0625eaf8902f9 which reverted a commit
by accident.


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/ff5d215b
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/ff5d215b
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/ff5d215b

Branch: refs/heads/master
Commit: ff5d215b54cb9a77e3742dc5dd05865dec08795b
Parents: 286c7ff
Author: Christian Schulte <schulte@apache.org>
Authored: Sun Dec 18 04:27:20 2016 +0100
Committer: Christian Schulte <schulte@apache.org>
Committed: Sun Dec 18 04:27:37 2016 +0100

----------------------------------------------------------------------
 .../transfer/AbstractMavenTransferListener.java | 32 +++++++++++++-------
 .../transfer/Slf4jMavenTransferListener.java    | 31 +++++++++++++------
 2 files changed, 42 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/ff5d215b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
index e72aa47..2286510 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
@@ -23,7 +23,6 @@ import java.io.PrintStream;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.util.Locale;
-
 import org.apache.commons.lang3.Validate;
 import org.eclipse.aether.transfer.AbstractTransferListener;
 import org.eclipse.aether.transfer.TransferCancelledException;
@@ -217,9 +216,15 @@ public abstract class AbstractMavenTransferListener
     public void transferInitiated( TransferEvent event )
     {
         String type = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading"
: "Downloading";
+        String direction = event.getRequestType() == TransferEvent.RequestType.PUT ? "to"
: "from";
 
         TransferResource resource = event.getResource();
-        out.println( type + ": " + resource.getRepositoryUrl() + resource.getResourceName()
);
+        StringBuilder message = new StringBuilder();
+        message.append( type ).append( ' ' ).append( direction ).append( ' ' ).append( resource.getRepositoryId()
);
+        message.append( ": " );
+        message.append( resource.getRepositoryUrl() ).append( resource.getResourceName()
);
+
+        out.println( message.toString() );
     }
 
     @Override
@@ -227,30 +232,35 @@ public abstract class AbstractMavenTransferListener
         throws TransferCancelledException
     {
         TransferResource resource = event.getResource();
-        out.println( "[WARNING] " + event.getException().getMessage() + " for " + resource.getRepositoryUrl()
-            + resource.getResourceName() );
+        out.println( "[WARNING] " + event.getException().getMessage() + " from " + resource.getRepositoryId()
+ " for "
+            + resource.getRepositoryUrl() + resource.getResourceName() );
     }
 
     @Override
     public void transferSucceeded( TransferEvent event )
     {
+        String type = ( event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded"
: "Downloaded" );
+        String direction = event.getRequestType() == TransferEvent.RequestType.PUT ? "to"
: "from";
+
         TransferResource resource = event.getResource();
         long contentLength = event.getTransferredBytes();
-
         FileSizeFormat format = new FileSizeFormat( Locale.ENGLISH );
-        String type = ( event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded"
: "Downloaded" );
-        String len = format.format( contentLength );
 
-        String throughput = "";
+        StringBuilder message = new StringBuilder();
+        message.append( type ).append( ' ' ).append( direction ).append( ' ' ).append( resource.getRepositoryId()
);
+        message.append( ": " );
+        message.append( resource.getRepositoryUrl() ).append( resource.getResourceName()
);
+        message.append( " (" ).append( format.format( contentLength ) );
+
         long duration = System.currentTimeMillis() - resource.getTransferStartTime();
         if ( duration > 0L )
         {
             double bytesPerSecond = contentLength / ( duration / 1000.0 );
-            throughput = " at " + format.format( (long) bytesPerSecond ) + "/s";
+            message.append( " at " ).append( format.format( (long) bytesPerSecond ) ).append(
"/s" );
         }
 
-        out.println( type + ": " + resource.getRepositoryUrl() + resource.getResourceName()
+ " (" + len
-            + throughput + ")" );
+        message.append( ')' );
+        out.println( message.toString() );
     }
 
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/ff5d215b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java
b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java
index 5bfb7b4..5d1144a 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java
@@ -50,9 +50,15 @@ public class Slf4jMavenTransferListener
     public void transferInitiated( TransferEvent event )
     {
         String type = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading"
: "Downloading";
+        String direction = event.getRequestType() == TransferEvent.RequestType.PUT ? "to"
: "from";
 
         TransferResource resource = event.getResource();
-        out.info( type + ": " + resource.getRepositoryUrl() + resource.getResourceName()
);
+        StringBuilder message = new StringBuilder();
+        message.append( type ).append( ' ' ).append( direction ).append( ' ' ).append( resource.getRepositoryId()
);
+        message.append( ": " );
+        message.append( resource.getRepositoryUrl() ).append( resource.getResourceName()
);
+
+        out.info( message.toString() );
     }
 
     @Override
@@ -60,30 +66,35 @@ public class Slf4jMavenTransferListener
         throws TransferCancelledException
     {
         TransferResource resource = event.getResource();
-        out.warn( event.getException().getMessage() + " for " + resource.getRepositoryUrl()
-            + resource.getResourceName() );
+        out.warn( event.getException().getMessage() + " from " + resource.getRepositoryId()
+ " for "
+            + resource.getRepositoryUrl() + resource.getResourceName() );
     }
 
     @Override
     public void transferSucceeded( TransferEvent event )
     {
+        String type = ( event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded"
: "Downloaded" );
+        String direction = event.getRequestType() == TransferEvent.RequestType.PUT ? "to"
: "from";
+
         TransferResource resource = event.getResource();
         long contentLength = event.getTransferredBytes();
-
         FileSizeFormat format = new FileSizeFormat( Locale.ENGLISH );
-        String type = ( event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded"
: "Downloaded" );
-        String len = format.format( contentLength );
 
-        String throughput = "";
+        StringBuilder message = new StringBuilder();
+        message.append( type ).append( ' ' ).append( direction ).append( ' ' ).append( resource.getRepositoryId()
);
+        message.append( ": " );
+        message.append( resource.getRepositoryUrl() ).append( resource.getResourceName()
);
+        message.append( " (" ).append( format.format( contentLength ) );
+
         long duration = System.currentTimeMillis() - resource.getTransferStartTime();
         if ( duration > 0L )
         {
             double bytesPerSecond = contentLength / ( duration / 1000.0 );
-            throughput = " at " + format.format( (long) bytesPerSecond ) + "/s";
+            message.append( " at " ).append( format.format( (long) bytesPerSecond ) ).append(
"/s" );
         }
 
-        out.info( type + ": " + resource.getRepositoryUrl() + resource.getResourceName()
+ " (" + len
-            + throughput + ")" );
+        message.append( ')' );
+        out.info( message.toString() );
     }
 
 }


Mime
View raw message