maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r720043 - in /maven/components/branches/maven-2.1.x: ./ maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java
Date Sun, 23 Nov 2008 21:15:31 GMT
Author: bentmann
Date: Sun Nov 23 13:15:31 2008
New Revision: 720043

URL: http://svn.apache.org/viewvc?rev=720043&view=rev
Log:
[MNG-3544] Beautify debug output for mojo parameters of type array

o Merged r720042 from maven-2.0.x

Modified:
    maven/components/branches/maven-2.1.x/   (props changed)
    maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java

Propchange: maven/components/branches/maven-2.1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 23 13:15:31 2008
@@ -1,5 +1,5 @@
 /maven/components/branches/maven-2.0.10-RC:679193-679867,680477-688882
-/maven/components/branches/maven-2.0.x:679552-679867,709032,709208,709241
+/maven/components/branches/maven-2.0.x:679552-679867,709032,709208,709241,720042
 /maven/components/branches/maven-2.1.0-M1-RC:690315,691793-694304
 /maven/components/branches/maven-2.1.0-RC:688883,689695,689976,689990
 /maven/components/trunk:720001

Modified: maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java?rev=720043&r1=720042&r2=720043&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java
(original)
+++ maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java
Sun Nov 23 13:15:31 2008
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+import java.lang.reflect.Array;
+
 import org.codehaus.plexus.component.configurator.ConfigurationListener;
 import org.codehaus.plexus.logging.Logger;
 
@@ -42,7 +44,7 @@
     {
         if ( logger.isDebugEnabled() )
         {
-            logger.debug( "  (s) " + fieldName + " = " + value );
+            logger.debug( "  (s) " + fieldName + " = " + toString( value ) );
         }
     }
 
@@ -50,7 +52,40 @@
     {
         if ( logger.isDebugEnabled() )
         {
-            logger.debug( "  (f) " + fieldName + " = " + value );
+            logger.debug( "  (f) " + fieldName + " = " + toString( value ) );
         }
     }
+
+    /**
+     * Creates a human-friendly string represenation of the specified object.
+     * 
+     * @param obj The object to create a string representation for, may be <code>null</code>.
+     * @return The string representation, never <code>null</code>.
+     */
+    private String toString( Object obj )
+    {
+        String str;
+        if ( obj != null && obj.getClass().isArray() )
+        {
+            int n = Array.getLength( obj );
+            StringBuffer buf = new StringBuffer( 256 );
+            buf.append( '[' );
+            for ( int i = 0; i < n; i++ )
+            {
+                if ( i > 0 )
+                {
+                    buf.append( ", " );
+                }
+                buf.append( String.valueOf( Array.get( obj, i ) ) );
+            }
+            buf.append( ']' );
+            str = buf.toString();
+        }
+        else
+        {
+            str = String.valueOf( obj );
+        }
+        return str;
+    }
+
 }



Mime
View raw message