maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r653052 - in /maven/artifact/branches/MNG-3010/src: main/java/org/apache/maven/artifact/versioning/ComparableVersion.java test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
Date Sat, 03 May 2008 11:21:02 GMT
Author: hboutemy
Date: Sat May  3 04:21:01 2008
New Revision: 653052

URL: http://svn.apache.org/viewvc?rev=653052&view=rev
Log:
added aliases: cr = rc, ga = final = ""

Modified:
    maven/artifact/branches/MNG-3010/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java
    maven/artifact/branches/MNG-3010/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java

Modified: maven/artifact/branches/MNG-3010/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java
URL: http://svn.apache.org/viewvc/maven/artifact/branches/MNG-3010/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java?rev=653052&r1=653051&r2=653052&view=diff
==============================================================================
--- maven/artifact/branches/MNG-3010/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java
(original)
+++ maven/artifact/branches/MNG-3010/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java
Sat May  3 04:21:01 2008
@@ -24,6 +24,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Properties;
 import java.util.Locale;
 
 /**
@@ -52,6 +53,8 @@
         public int compareTo( Item item );
 
         public int getType();
+
+        public boolean isNull();
     }
 
     /**
@@ -72,6 +75,11 @@
             return INTEGER_ITEM;
         }
 
+        public boolean isNull()
+        {
+            return ( value.intValue() == 0 );
+        }
+
         public int compareTo( Item item )
         {
             if ( item == null )
@@ -107,10 +115,16 @@
     private static class StringItem
         implements Item
     {
-        private final static String[] QUALIFIERS = { "snapshot", "alpha", "beta", "rc", "",
"ga", "sp" };
+        private final static String[] QUALIFIERS = { "snapshot", "alpha", "beta", "rc", "",
"sp" };
 
         private final static List _QUALIFIERS = Arrays.asList( QUALIFIERS );
 
+        private final static Properties ALIASES = new Properties();
+        static {
+            ALIASES.put( "ga", "" );
+            ALIASES.put( "final", "" );
+            ALIASES.put( "cr", "rc" );
+        }
         /**
          * A comparable for the empty-string qualifier. This one is used to determine if
a given qualifier makes the
          * version older than one without a qualifier, or more recent.
@@ -129,6 +143,11 @@
             return STRING_ITEM;
         }
 
+        public boolean isNull()
+        {
+            return ( comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ) == 0
);
+        }
+
         /**
          * Returns a comparable for a qualifier.
          *
@@ -144,6 +163,8 @@
          */
         public static Comparable comparableQualifier( String qualifier )
         {
+            qualifier = ALIASES.getProperty( qualifier, qualifier );
+
             int i = _QUALIFIERS.indexOf( qualifier );
 
             return i == -1 ? _QUALIFIERS.size() + "-" + qualifier : String.valueOf( i );
@@ -191,14 +212,19 @@
             return LIST_ITEM;
         }
 
+        public boolean isNull()
+        {
+            return ( size() == 0 );
+        }
+
         void normalize()
         {
             for( ListIterator iterator = listIterator( size() ); iterator.hasPrevious();
)
             {
                 Item item = (Item) iterator.previous();
-                if ( item.getType() == INTEGER_ITEM && ( ( (IntegerItem) item ).value
== 0 ) )
+                if ( item.isNull() )
                 {
-                    iterator.remove(); // remove trailing zeros
+                    iterator.remove(); // remove null trailing items: 0, "", empty list
                 }
                 else
                 {

Modified: maven/artifact/branches/MNG-3010/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
URL: http://svn.apache.org/viewvc/maven/artifact/branches/MNG-3010/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java?rev=653052&r1=653051&r2=653052&view=diff
==============================================================================
--- maven/artifact/branches/MNG-3010/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
(original)
+++ maven/artifact/branches/MNG-3010/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
Sat May  3 04:21:01 2008
@@ -38,8 +38,8 @@
     }
 
     private static final String[] VERSIONS_QUALIFIER = {
-        "1-SNAPSHOT", "1-alpha2snapshot", "1-alpha2", "1-alpha-123", "1-beta-2", "1-beta123",
"1-rc", "1-rc2", "1-rc123",
-        "1", "1-ga", "1-sp2", "1-sp123", "1-abc", "1-def", "1-1-snapshot", "1-1", "1-2",
"1-123"
+        "1-SNAPSHOT", "1-alpha2snapshot", "1-alpha2", "1-alpha-123", "1-beta-2", "1-beta123",
"1-rc", "1-cr2", "1-rc123",
+        "1", "1-sp", "1-sp2", "1-sp123", "1-abc", "1-def", "1-1-snapshot", "1-1", "1-2",
"1-123"
     };
 
     private static final String[] VERSIONS_NUMBER = {
@@ -108,6 +108,11 @@
         checkVersionsEqual( "1a", "1.0.0-a" );
         checkVersionsEqual( "1.0a", "1.0.a" );
         checkVersionsEqual( "1.0.0a", "1.0.0.a" );
+
+        // aliases
+        checkVersionsEqual( "1ga", "1" );
+        checkVersionsEqual( "1final", "1" );
+        checkVersionsEqual( "1cr", "1rc" );
     }
 
     public void testVersionComparing()



Mime
View raw message