This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch maven-3.8.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-3.8.x by this push:
new 9189425 [MNG-6967] Improve the command line output from
maven-artifact.
9189425 is described below
commit 91894251505fe917b911885d565e6bc1c8bebadd
Author: Dennis Lundberg <[email protected]>
AuthorDate: Wed Jul 22 11:01:35 2020 +0200
[MNG-6967] Improve the command line output from maven-artifact.
---
.../artifact/versioning/ComparableVersion.java | 33 ++++++++++++++++++++--
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git
a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java
b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java
index 23eb846..41a9ad1 100644
---
a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java
+++
b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java
@@ -590,6 +590,32 @@ public class ComparableVersion
}
return buffer.toString();
}
+
+ /**
+ * Return the contents in the same format that is used when you call
toString() on a List.
+ */
+ private String toListString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append( "[" );
+ for ( Item item : this )
+ {
+ if ( buffer.length() > 1 )
+ {
+ buffer.append( ", " );
+ }
+ if ( item instanceof ListItem )
+ {
+ buffer.append( ( (ListItem ) item ).toListString() );
+ }
+ else
+ {
+ buffer.append( item );
+ }
+ }
+ buffer.append( "]" );
+ return buffer.toString();
+ }
}
public ComparableVersion( String version )
@@ -773,10 +799,10 @@ public class ComparableVersion
* @param args the version strings to parse and compare. You can pass
arbitrary number of version strings and always
* two adjacent will be compared
*/
- // CHECKSTYLE_ON: LineLength
public static void main( String... args )
{
- System.out.println( "Display parameters as parsed by Maven (in
canonical form) and comparison result:" );
+ System.out.println( "Display parameters as parsed by Maven (in
canonical form and as a list of tokens) and"
+ + " comparison result:" );
if ( args.length == 0 )
{
return;
@@ -795,9 +821,10 @@ public class ComparableVersion
+ ( ( compare == 0 ) ? "==" : ( ( compare < 0 ) ? "<" :
">" ) ) + ' ' + version );
}
- System.out.println( String.valueOf( i++ ) + ". " + version + " ==
" + c.getCanonical() );
+ System.out.println( ( i++ ) + ". " + version + " -> " +
c.getCanonical() + "; tokens: " + c.items.toListString() );
prev = c;
}
}
+ // CHECKSTYLE_ON: LineLength
}