Repository: maven
Updated Branches:
  refs/heads/MNG-5457 [created] 8c346f00e


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


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

Branch: refs/heads/MNG-5457
Commit: 8c346f00efccf60198d2d6a630c3b0d05d023d49
Parents: 14182b8
Author: Michael Osipov <micha...@apache.org>
Authored: Fri Jul 15 23:26:56 2016 +0200
Committer: Michael Osipov <micha...@apache.org>
Committed: Sun Oct 16 21:02:58 2016 +0200

----------------------------------------------------------------------
 .../transfer/AbstractMavenTransferListener.java | 32 +++++++++++++-------
 .../transfer/Slf4jMavenTransferListener.java    | 31 +++++++++++++------
 pom.xml                                         |  2 +-
 3 files changed, 43 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/8c346f00/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/8c346f00/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() );
     }
 
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/8c346f00/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c447507..65140a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,7 @@ under the License.
     <cipherVersion>1.7</cipherVersion>
     <modelloVersion>1.8.3</modelloVersion>
     <jxpathVersion>1.3</jxpathVersion>
-    <aetherVersion>1.0.2.v20150114</aetherVersion>
+    <aetherVersion>1.1.0-SNAPSHOT</aetherVersion>
     <!-- Upgrade of SLF4J blocked by SLF4J-370 (MNG-6023). -->
     <!--   https://issues.apache.org/jira/browse/MNG-6023  -->
     <!--   http://jira.qos.ch/browse/SLF4J-370             -->

Reply via email to