maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1296476 - in /maven/release/trunk/maven-release-manager/src: main/java/org/apache/maven/shared/release/versions/DefaultVersionInfo.java test/java/org/apache/maven/shared/release/versions/DefaultVersionInfoTest.java
Date Fri, 02 Mar 2012 21:15:09 GMT
Author: rfscholte
Date: Fri Mar  2 21:15:09 2012
New Revision: 1296476

URL: http://svn.apache.org/viewvc?rev=1296476&view=rev
Log:
Fix MRELEASE-623: unexpected mvn release:prepare behavior for project with <version>2.2-SNAPshot</version>

Modified:
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/versions/DefaultVersionInfo.java
    maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/versions/DefaultVersionInfoTest.java

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/versions/DefaultVersionInfo.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/versions/DefaultVersionInfo.java?rev=1296476&r1=1296475&r2=1296476&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/versions/DefaultVersionInfo.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/versions/DefaultVersionInfo.java
Fri Mar  2 21:15:09 2012
@@ -20,6 +20,7 @@ package org.apache.maven.shared.release.
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -187,16 +188,7 @@ public class DefaultVersionInfo
 
     public boolean isSnapshot()
     {
-        // TODO: ripped from Artifact. Should be in ArtifactVersion -> move.
-        Matcher m = Artifact.VERSION_FILE_PATTERN.matcher( strVersion );
-        if ( m.matches() )
-        {
-            return true;
-        }
-        else
-        {
-            return strVersion.endsWith( Artifact.SNAPSHOT_VERSION ) || strVersion.equals(
Artifact.LATEST_VERSION );
-        }
+        return ArtifactUtils.isSnapshot( strVersion );
     }
 
     public VersionInfo getNextVersion()
@@ -311,7 +303,8 @@ public class DefaultVersionInfo
         {
             baseVersion = m.group( 1 );
         }
-        else if ( baseVersion.endsWith( "-" + Artifact.SNAPSHOT_VERSION ) )
+        // MRELEASE-623 SNAPSHOT is case-insensitive
+        else if ( StringUtils.right( baseVersion, 9 ).equalsIgnoreCase( "-" + Artifact.SNAPSHOT_VERSION
) )
         {
             baseVersion = baseVersion.substring( 0, baseVersion.length() - Artifact.SNAPSHOT_VERSION.length()
- 1 );
         }

Modified: maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/versions/DefaultVersionInfoTest.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/versions/DefaultVersionInfoTest.java?rev=1296476&r1=1296475&r2=1296476&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/versions/DefaultVersionInfoTest.java
(original)
+++ maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/versions/DefaultVersionInfoTest.java
Fri Mar  2 21:15:09 2012
@@ -137,6 +137,9 @@ public class DefaultVersionInfoTest
         checkNextVersion( "1.009", "1.010" );
 
         checkNextVersion( "1.99", "1.100" );
+        
+        //MRELEASE-623 SNAPSHOT is case-insensitive
+        checkNextVersion( "2.2-SNAPshot", "2.3-SNAPshot" );
     }
 
     public void testNextAnnotationRevision()
@@ -240,7 +243,24 @@ public class DefaultVersionInfoTest
         assertTrue( new DefaultVersionInfo( "1.01-beta-04-SNAPSHOT" ).isSnapshot() );
         assertTrue( new DefaultVersionInfo( "1.01-beta-04-20051112.134500-1" ).isSnapshot()
);
         assertFalse( new DefaultVersionInfo( "1.01-beta-04_20051112.134500-1" ).isSnapshot()
);
+        
     }
+    
+    //MRELEASE-623 SNAPSHOT is case-insensitive
+    public void testCaseInsensitiveSnapshot() throws VersionParseException
+    {
+        DefaultVersionInfo currentVersionInfo = new DefaultVersionInfo( "2.2-SNAPshot" );

+        assertTrue( currentVersionInfo.isSnapshot()  );
+        assertEquals( "2.2", currentVersionInfo.getReleaseVersionString() );
+        VersionInfo nextVersionInfo = currentVersionInfo.getNextVersion();
+        assertEquals( "2.3-SNAPSHOT", nextVersionInfo.getSnapshotVersionString() );
+    }
+
+//    Ignore, new DefaultVersionInfo( "LATEST") throws VersionParseException
+//    public void testLatest() throws VersionParseException
+//    {
+//        assertTrue( new DefaultVersionInfo( "LATEST") .isSnapshot() );
+//    }
 
     private static void checkGetReleaseVersion( String strVersion, String expected )
         throws Exception



Mime
View raw message