Author: evenisse
Date: Thu Nov 17 06:58:21 2005
New Revision: 345255

URL: http://svn.apache.org/viewcvs?rev=345255&view=rev
Log:
PR: MNG-1556²
Submitted by: David Hawkins
Reviewed by : Emmanuel Venisse

This patch makes the maven-release-plugin no longer specify the tagBase by 
default. It will now play nicely with the changes made to the 
maven-scm-provider-svn in SCM-72.

The other significant change is that I made the version resolution a little 
smarter. I was tired of it not understanding my 3 digit versions (1.1.1). It 
now understands quite a few different ways of specifying the version and should 
be able to generate the next version as well as a snapshot version string. 
While it is quite robust, I wrote it with the thought that others could 
implement the interface if they wanted to use their own versioning scheme. I 
have the ProjectVersionResolver.getResolvedVersion explicitly instantiating the 
DefaultVersionInfo class because I am not sure what the best pattern is to have 
the container handle it. If someone wanted to insert their own class for the 
impl, how could they go about configuring it to do so? I also had the 
VersionInfo object implement comparable even though it isn't used right now. I 
can think of a couple places that might come in handy.

Added:
    
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/
    
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/DefaultVersionInfo.java
   (with props)
    
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionInfo.java
   (with props)
    
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionParseException.java
   (with props)
    maven/plugins/trunk/maven-release-plugin/src/test/
    maven/plugins/trunk/maven-release-plugin/src/test/java/
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/
    
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/
    
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/
    
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/versions/
    
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/versions/DefaultVersionInfoTest.java
   (with props)
Modified:
    
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
    
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java
    
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java

Modified: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java?rev=345255&r1=345254&r2=345255&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
 Thu Nov 17 06:58:21 2005
@@ -156,7 +156,7 @@
     private String tag;
 
     /**
-     * @parameter expression="${tagBase}" default-value="../tags"
+     * @parameter expression="${tagBase}"
      */
     private String tagBase;
 
@@ -464,7 +464,7 @@
             }
 
             if ( releaseProgress.getUsername() == null || 
releaseProgress.getScmTag() == null ||
-                releaseProgress.getScmTagBase() == null || 
releaseProgress.getScmUrl() == null )
+                 releaseProgress.getScmUrl() == null )
             {
                 throw new MojoExecutionException( "Missing release preparation 
information." );
             }

Modified: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java?rev=345255&r1=345254&r2=345255&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java
 (original)
+++ 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java
 Thu Nov 17 06:58:21 2005
@@ -16,21 +16,22 @@
  * limitations under the License.
  */
 
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.model.Model;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugins.release.versions.DefaultVersionInfo;
+import org.apache.maven.plugins.release.versions.VersionInfo;
+import org.apache.maven.plugins.release.versions.VersionParseException;
 import org.codehaus.plexus.components.interactivity.InputHandler;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
 public class ProjectVersionResolver
 {
-    private static final String SNAPSHOT_CLASSIFIER = "-SNAPSHOT";
-
     private Map resolvedVersions = new HashMap();
 
     private final Log log;
@@ -56,132 +57,92 @@
         }
 
         //Rewrite project version
-        String projectVersion = model.getVersion();
-
-        if ( !projectVersion.endsWith( SNAPSHOT_CLASSIFIER ) )
-        {
-            throw new IllegalArgumentException( "Project version isn't a 
snapshot, it must ends with '" + SNAPSHOT_CLASSIFIER + "'." );
-        }
+        VersionInfo version = getVersionInfo( model.getVersion() );
 
-        projectVersion = projectVersion.substring( 0, projectVersion.length() 
- SNAPSHOT_CLASSIFIER.length() );
+        String projectVersion = ( version != null ) ? 
version.getReleaseVersionString() : null;
 
         if ( interactive )
         {
-            try
-            {
-                log.info( "What is the release version for \'" + projectId + 
"\'? [" + projectVersion + "]" );
-
-                String inputVersion = inputHandler.readLine();
-
-                if ( !StringUtils.isEmpty( inputVersion ) )
-                {
-                    projectVersion = inputVersion;
-                }
-            }
-            catch ( IOException e )
-            {
-                throw new MojoExecutionException( "Can't read release version 
from user input.", e );
-            }
+            projectVersion = getVersionFromUser("What is the release version 
for \'" + projectId + "\'?", projectVersion);
+        } 
+        else if ( StringUtils.isEmpty( projectVersion ) ) 
+        {
+            throw new MojoExecutionException("Unable to determine release 
project version");
         }
-
+        
         model.setVersion( projectVersion );
 
         resolvedVersions.put( projectId, projectVersion );
     }
 
-    public String getResolvedVersion( String groupId, String artifactId )
-    {
-        String projectId = ArtifactUtils.versionlessKey( groupId, artifactId );
-
-        return (String) resolvedVersions.get( projectId );
-    }
-
-    public void incrementVersion( Model model, String projectId )
+    private String getVersionFromUser(String promptText, String 
defaultVersionStr )
         throws MojoExecutionException
     {
-        String projectVersion = model.getVersion();
-
-        if ( ArtifactUtils.isSnapshot( projectVersion ) )
+        if ( defaultVersionStr != null )
         {
-            throw new MojoExecutionException( "The project " + projectId + " 
is a snapshot (" + projectVersion +
-                "). It appears that the release version has not been 
committed." );
+            promptText = promptText + "[" + defaultVersionStr + "]";
         }
+        
+        try
+        {
+            log.info( promptText );
 
-        // TODO: we will need to incorporate versioning strategies here 
because it is unlikely
-        // that everyone will be able to agree on a standard. This is 
extremely limited right
-        // now and really only works for the way maven is versioned.
-
-        // releaseVersion = 1.0-beta-4
-        // snapshotVersion = 1.0-beta-5-SNAPSHOT
-        // or
-        // releaseVersion = 1.0.4
-        // snapshotVersion = 1.0.5-SNAPSHOT
-
-        String staticVersionPart;
-        String nextVersionString;
-
-        int rcIdx = projectVersion.toLowerCase().lastIndexOf( "-rc" );
-        int dashIdx = projectVersion.lastIndexOf( "-" );
-        int dotIdx = projectVersion.lastIndexOf( "." );
+            String inputVersion = inputHandler.readLine();
 
-        if ( rcIdx >= dashIdx )
-        {
-            staticVersionPart = projectVersion.substring( 0, rcIdx + 3 );
-            nextVersionString = projectVersion.substring( rcIdx + 3 );
-        }
-        else if ( dashIdx > 0 )
-        {
-            staticVersionPart = projectVersion.substring( 0, dashIdx + 1 );
-            nextVersionString = projectVersion.substring( dashIdx + 1 );
-        }
-        else if ( dotIdx > 0 )
-        {
-            staticVersionPart = projectVersion.substring( 0, dotIdx + 1 );
-            nextVersionString = projectVersion.substring( dotIdx + 1 );
+            return ( StringUtils.isEmpty( inputVersion ) ) ? defaultVersionStr 
: inputVersion;
         }
-        else
+        catch ( IOException e )
         {
-            staticVersionPart = "";
-            nextVersionString = projectVersion;
-        }
+            throw new MojoExecutionException( "Can't read version from user 
input.", e );
+        }        
+    }
+    
+    public String getResolvedVersion( String groupId, String artifactId )
+    {
+        String projectId = ArtifactUtils.versionlessKey( groupId, artifactId );
 
-        try
-        {
-            nextVersionString = Integer.toString( Integer.parseInt( 
nextVersionString ) + 1 );
+        return (String) resolvedVersions.get( projectId );
+    }
 
-            projectVersion = staticVersionPart + nextVersionString + 
SNAPSHOT_CLASSIFIER;
-        }
-        catch ( NumberFormatException e )
+    private VersionInfo getVersionInfo(String version) {
+        // TODO: Provide a way to override the implementation of VersionInfo
+        try 
         {
-            projectVersion = "";
+            return new DefaultVersionInfo( version );
+        } 
+        catch (VersionParseException e)
+        {
+            return null;
+        }
+        
+    }
+    
+    public void incrementVersion( Model model, String projectId )
+        throws MojoExecutionException
+    {
+        VersionInfo version = getVersionInfo( model.getVersion() );
+        
+        if ( version != null && version.isSnapshot() )
+        {
+            throw new MojoExecutionException( "The project " + projectId + " 
is a snapshot ("
+                + version.getVersionString() + "). It appears that the release 
version has not been committed." );
         }
 
+        VersionInfo nextVersionInfo = ( version != null ) ? 
version.getNextVersion() : null;
+        
+        String nextVersion = (nextVersionInfo != null) ? 
nextVersionInfo.getSnapshotVersionString() : null;
+        
         if ( interactive )
         {
-            try
-            {
-                log.info( "What is the new development version for \'" + 
projectId + "\'? [" + projectVersion + "]" );
-
-                String inputVersion = inputHandler.readLine();
-
-                if ( !StringUtils.isEmpty( inputVersion ) )
-                {
-                    projectVersion = inputVersion;
-                }
-            }
-            catch ( IOException e )
-            {
-                throw new MojoExecutionException( "Can't read next development 
version from user input.", e );
-            }
+            nextVersion = getVersionFromUser("What is the new development 
version for \'" + projectId + "\'?", nextVersion );            
         }
-        else if ( "".equals( projectVersion ) )
+        else if ( nextVersion == null )
         {
             throw new MojoExecutionException( "Cannot determine incremented 
development version for: " + projectId );
         }
 
-        model.setVersion( projectVersion );
+        model.setVersion( nextVersion );
 
-        resolvedVersions.put( projectId, projectVersion );
+        resolvedVersions.put( projectId, nextVersion );
     }
-
 }

Modified: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java?rev=345255&r1=345254&r2=345255&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java
 (original)
+++ 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java
 Thu Nov 17 06:58:21 2005
@@ -2,6 +2,7 @@
 
 import org.apache.maven.model.Scm;
 import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -104,6 +105,14 @@
 
         return new ReleaseProgressTracker( rp );
     }
+    
+    protected void setReleaseProperty( String key, String value )
+    {
+        if ( StringUtils.isNotEmpty( value ) )
+        {
+            releaseProperties.setProperty( key, value );
+        }
+    }
 
     public static String getReleaseProgressFilename()
     {
@@ -112,7 +121,7 @@
 
     public void setUsername( String username )
     {
-        releaseProperties.setProperty( USERNAME, username );
+        setReleaseProperty( USERNAME, username );
     }
 
     public String getUsername()
@@ -122,7 +131,7 @@
 
     public void setScmTag( String scmTag )
     {
-        releaseProperties.setProperty( SCM_TAG, scmTag );
+        setReleaseProperty( SCM_TAG, scmTag );
     }
 
     public String getScmTag()
@@ -132,7 +141,7 @@
 
     public void setScmUrl( String scmUrl )
     {
-        releaseProperties.setProperty( SCM_URL, scmUrl );
+        setReleaseProperty( SCM_URL, scmUrl );
     }
 
     public String getScmUrl()
@@ -142,7 +151,7 @@
 
     public void setScmTagBase( String tagBase )
     {
-        releaseProperties.setProperty( SCM_TAG_BASE, tagBase );
+        setReleaseProperty( SCM_TAG_BASE, tagBase );
     }
 
     public String getScmTagBase()
@@ -152,7 +161,7 @@
 
     public void setPassword( String password )
     {
-        releaseProperties.setProperty( SCM_PASSWORD, password );
+        setReleaseProperty( SCM_PASSWORD, password );
     }
 
     public String getPassword()
@@ -183,7 +192,7 @@
 
     private void setCheckpoint( String pointName )
     {
-        releaseProperties.setProperty( CHECKPOINT_PREFIX + pointName, "OK" );
+        setReleaseProperty( CHECKPOINT_PREFIX + pointName, "OK" );
     }
 
     public boolean verifyCheckpoint( String pointName )
@@ -201,25 +210,25 @@
         String connection = scm.getConnection();
         if ( connection != null )
         {
-            releaseProperties.setProperty( SCM_INFO_PREFIX + projectId + 
".connection", connection );
+            setReleaseProperty( SCM_INFO_PREFIX + projectId + ".connection", 
connection );
         }
 
         String devConnection = scm.getDeveloperConnection();
         if ( devConnection != null )
         {
-            releaseProperties.setProperty( SCM_INFO_PREFIX + projectId + 
".developerConnection", devConnection );
+            setReleaseProperty( SCM_INFO_PREFIX + projectId + 
".developerConnection", devConnection );
         }
 
         String url = scm.getUrl();
         if ( url != null )
         {
-            releaseProperties.setProperty( SCM_INFO_PREFIX + projectId + 
".url", url );
+            setReleaseProperty( SCM_INFO_PREFIX + projectId + ".url", url );
         }
 
         String tag = scm.getTag();
         if ( tag != null )
         {
-            releaseProperties.setProperty( SCM_INFO_PREFIX + projectId + 
".tag", tag );
+            setReleaseProperty( SCM_INFO_PREFIX + projectId + ".tag", tag );
         }
     }
 

Added: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/DefaultVersionInfo.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/DefaultVersionInfo.java?rev=345255&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/DefaultVersionInfo.java
 (added)
+++ 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/DefaultVersionInfo.java
 Thu Nov 17 06:58:21 2005
@@ -0,0 +1,498 @@
+package org.apache.maven.plugins.release.versions;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.codehaus.plexus.util.StringUtils;
+
+/** This compares and increments versions for a common java versioning scheme.
+ * <p>
+ * The supported version scheme has the following parts.<br>
+ * 
<code><i>component-digits-annotation-annotationRevision-buildSpecifier</i></code><br>
+ * Example:<br>
+ * <code>my-component-1.0.1-alpha-2-SNAPSHOT</code>
+ * 
+ * <ul>Terms:
+ *  <li><i>component</i> - name of the versioned component (log4j, 
commons-lang, etc)
+ *  <li><i>digits</i> - Numeric digits with at least one "." period. (1.0, 
1.1, 1.01, 1.2.3, etc)
+ *  <li><i>annotation</i> - Version annotation - Valid Values are (alpha, 
beta, RC).
+ *   Use [EMAIL PROTECTED] DefaultVersionInfo#setAnnotationOrder(List)} to 
change the valid values.
+ *  <li><i>annotationRevision</i> - Integer qualifier for the annotation. (4 
as in RC-4)
+ *  <li><i>buildSpecifier</i> - Additional specifier for build. (SNAPSHOT, or 
build number like "20041114.081234-2")
+ * </ul>
+ * <b>Digits is the only required piece of the version string, and must 
contain at lease one "." period.</b>
+ * <p>
+ * Implementation details:<br>
+ * The separators "_" and "-" between components are also optional (though 
they are usually reccommended).<br>
+ * Example:<br>
+ * <code>log4j-1.2.9-beta-9-SNAPSHOT == log4j1.2.9beta9SNAPSHOT == 
log4j_1.2.9_beta_9_SNAPSHOT</code>
+ * <p>
+ * All numbers in the "digits" part of the version are considered Integers. 
Therefore 1.01.01 is the same as 1.1.1
+ * Leading zeros are ignored when performing comparisons.
+ *
+ */
+public class DefaultVersionInfo
+    implements VersionInfo, Cloneable
+{
+    protected String strVersion;
+
+    protected String component;
+
+    protected List digits;
+
+    protected String annotation;
+
+    protected String annotationRevision;
+
+    protected String buildSpecifier;
+
+    protected String digitSeparator;
+
+    protected String annotationSeparator;
+
+    protected String annotationRevSeparator;
+
+    protected String buildSeparator;
+    
+    protected List annotationOrder;
+    
+    private final static int COMPONENT_INDEX = 1;
+
+    private final static int DIGIT_SEPARATOR_INDEX = 2;
+
+    private final static int DIGITS_INDEX = 3;
+
+    private final static int ANNOTATION_SEPARATOR_INDEX = 4;
+
+    private final static int ANNOTATION_INDEX = 5;
+
+    private final static int ANNOTATION_REV_SEPARATOR_INDEX = 6;
+
+    private final static int ANNOTATION_REVISION_INDEX = 7;
+
+    private final static int BUILD_SEPARATOR_INDEX = 8;
+
+    private final static int BUILD_SPECIFIER_INDEX = 9;
+
+    public static final String SNAPSHOT_IDENTIFIER = "SNAPSHOT";
+    
+    protected final static String DIGIT_SEPARATOR_STRING = ".";
+
+    protected final static Pattern STANDARD_PATTERN = Pattern.compile( 
+        "^(.*?)" +                  // non greedy .* to grab the component. 
+        "([-_])?" +                 // optional - or _  (digits separator)
+        "((?:\\d+[.])+\\d+)" +      // digit(s) and '.' repeated - followed by 
digit (version digits 1.22.0, etc)
+        "([-_])?" +                 // optional - or _  (annotation separator)
+        "([a-zA-Z]*)" +             // alpha characters (looking for 
annotation - alpha, beta, RC, etc.)
+        "([-_])?" +                 // optional - or _  (annotation revision 
separator)
+        "(\\d*)" +                  // digits  (any digits after rc or beta is 
an annotation revision)
+        "(?:([-_])?(.*?))?$");      // - or _ followed everything else (build 
specifier)
+    
+    protected final static Pattern DIGIT_SEPARATOR_PATTERN = Pattern.compile( 
"(\\d+)\\.?" );
+    
+    /** Constructs this object and parses the supplied version string.
+     *  
+     * @param version
+     */
+    public DefaultVersionInfo( String version )
+        throws VersionParseException
+    {
+        // TODO: How to handle M (Milestone) or 1.1b (Beta)
+        annotationOrder = Arrays.asList( new String[] { "ALPHA", "BETA", "RC" 
} );
+
+        parseVersion( version );
+    }
+    
+    /** Internal routine for parsing the supplied version string into its 
parts. 
+     * 
+     * @param version
+     */
+    protected void parseVersion( String version )
+        throws VersionParseException
+    {
+        this.strVersion = version;
+
+        Matcher m = STANDARD_PATTERN.matcher( strVersion );
+        if ( m.matches() )
+        {
+            setComponent( m.group( COMPONENT_INDEX ) );
+            this.digitSeparator = m.group( DIGIT_SEPARATOR_INDEX );
+            setDigits( parseDigits( m.group( DIGITS_INDEX ) ) );
+            if ( !SNAPSHOT_IDENTIFIER.equals( m.group( ANNOTATION_INDEX ) ) )
+            {
+                this.annotationSeparator = m.group( ANNOTATION_SEPARATOR_INDEX 
);
+                setAnnotation( m.group( ANNOTATION_INDEX ) );
+
+                if ( StringUtils.isNotEmpty( m.group( 
ANNOTATION_REV_SEPARATOR_INDEX ) )
+                    && StringUtils.isEmpty( m.group( ANNOTATION_REVISION_INDEX 
) ) )
+                {
+                    // The build separator was picked up as the annotation 
revision separator
+                    this.buildSeparator = m.group( 
ANNOTATION_REV_SEPARATOR_INDEX );
+                    setBuildSpecifier( m.group( BUILD_SPECIFIER_INDEX ) );
+                }
+                else
+                {
+                    this.annotationRevSeparator = m.group( 
ANNOTATION_REV_SEPARATOR_INDEX );
+                    setAnnotationRevision( m.group( ANNOTATION_REVISION_INDEX 
) );
+
+                    this.buildSeparator = m.group( BUILD_SEPARATOR_INDEX );
+                    setBuildSpecifier( m.group( BUILD_SPECIFIER_INDEX ) );
+                }
+            }
+            else
+            {
+                // Annotation was "SNAPSHOT" so populate the build specifier 
with that data
+                this.buildSeparator = m.group( ANNOTATION_SEPARATOR_INDEX );
+                setBuildSpecifier( m.group( ANNOTATION_INDEX ) );
+            }
+        }
+        else
+        {
+            throw new VersionParseException( "Unable to parse the version 
string: \"" + version + "\"" );
+        }
+    }
+    
+    public boolean isSnapshot()
+    {
+        return SNAPSHOT_IDENTIFIER.equalsIgnoreCase( this.buildSpecifier );
+    }
+
+    public VersionInfo getNextVersion()
+    {
+        DefaultVersionInfo result;
+
+        try
+        {
+            result = (DefaultVersionInfo) this.clone();
+        }
+        catch ( CloneNotSupportedException e )
+        {
+            return null;
+        }
+
+        if ( StringUtils.isNumeric( result.annotationRevision ) )
+        {
+            result.annotationRevision = incrementVersionString( 
result.annotationRevision );
+        }
+        else if ( result.digits != null && !result.digits.isEmpty() )
+        {
+            try
+            {
+                List digits = result.digits;
+                digits.set( digits.size() - 1, incrementVersionString( 
(String) digits.get( digits.size() - 1 ) ) );
+            }
+            catch ( NumberFormatException e )
+            {
+                return null;
+            }
+        }
+        else
+        {
+            return null;
+        }
+
+        return result;
+    }
+    
+    /** Compares this [EMAIL PROTECTED] DefaultVersionInfo} to the supplied 
[EMAIL PROTECTED] DefaultVersionInfo}
+     * to determine which version is greater.
+     * <p>
+     * Decision order is: digits, annotation, annotationRev, buildSpecifier.
+     * <p>
+     * Presence of an annotation is considered to be less than an equivalent 
version without an annotation.<br>
+     * Example: 1.0 is greater than 1.0-alpha.<br> 
+     * <p> 
+     * The [EMAIL PROTECTED] DefaultVersionInfo#getAnnotationOrder()} is used 
in determining the rank order of annotations.<br>
+     * For example: alpha &lt; beta &lt; RC &lt release 
+     * 
+     * @param that
+     * @return
+     * @throws IllegalArgumentException if the components differ between the 
objects or if either of the annotations can not be determined.
+     */
+    public int compareTo( Object obj )
+    {
+        if ( !( obj instanceof DefaultVersionInfo ) )
+            throw new ClassCastException( "DefaultVersionInfo object expected" 
);
+
+        DefaultVersionInfo that = (DefaultVersionInfo) obj;
+
+        if ( !StringUtils.equals( this.component, that.component ) )
+        {
+            throw new IllegalArgumentException( "Cannot perform comparison on 
different components: \""
+                + this.component + "\" compared to \"" + that.component + "\"" 
);
+        }
+
+        if ( !this.digits.equals( that.digits ) )
+        {
+            for ( int i = 0; i < this.digits.size(); i++ )
+            {
+                if ( i >= that.digits.size() )
+                {
+                    // We've gone past the end of the digit list of that. We 
are greater
+                    return 1;
+                }
+
+                if ( !StringUtils.equals( (String) this.digits.get( i ), 
(String) that.digits.get( i ) ) )
+                {
+                    return compareToAsIntegers( (String) this.digits.get( i ), 
(String) that.digits.get( i ) );
+                }
+            }
+
+            if ( this.digits.size() < that.digits.size() )
+            {
+                // The lists were equal up to the end of this list. The other 
has more digits so it is greater.
+                return -1;
+            }
+        }
+
+        if ( !StringUtils.equalsIgnoreCase( this.annotation, that.annotation ) 
)
+        {
+            // Having an annotation vs. not is considered to be less than.
+            // a 1.0-alpha is less than 1.0
+            if ( this.annotation != null && that.annotation == null )
+            {
+                return -1;
+            }
+            else if ( this.annotation == null && that.annotation != null )
+            {
+                return 1;
+            }
+            else
+            {
+                int nThis = annotationOrder.indexOf( 
this.annotation.toUpperCase() );
+                int nThat = annotationOrder.indexOf( 
that.annotation.toUpperCase() );
+
+                if ( nThis == -1 || nThat == -1 )
+                {
+                    throw new IllegalArgumentException( "Cannot perform 
comparison on unknown annotation: \""
+                        + this.annotation + "\" compared to \"" + 
that.annotation + "\"" );
+                }
+
+                return nThis - nThat;
+            }
+        }
+
+        if ( !StringUtils.equals( this.annotationRevision, 
that.annotationRevision ) )
+        {
+            return compareToAsIntegers( this.annotationRevision, 
that.annotationRevision );
+        }
+
+        if ( !StringUtils.equals( this.buildSpecifier, that.buildSpecifier ) )
+        {
+            if ( this.buildSpecifier == null && that.buildSpecifier != null )
+            {
+                return 1;
+            }
+            else if ( this.buildSpecifier != null && that.buildSpecifier == 
null )
+            {
+                return -1;
+            }
+            else
+            {
+                // Just do a simple string comparison?
+                return this.buildSpecifier.compareTo( that.buildSpecifier );
+            }
+        }
+
+        return 0;
+    }
+
+    private int compareToAsIntegers( String s1, String s2 )
+    {
+        int n1 = StringUtils.isEmpty( s1 ) ? -1 : Integer.parseInt( s1 );
+        int n2 = StringUtils.isEmpty( s2 ) ? -1 : Integer.parseInt( s2 );
+
+        return n1 - n2;
+    }
+    
+    /** Takes a string and increments it as an integer.  
+     * Preserves any lpad of "0" zeros.
+     * 
+     * @param s
+     * @return
+     */
+    protected String incrementVersionString( String s )
+    {
+        if ( StringUtils.isEmpty( s ) )
+        {
+            return null;
+        }
+
+        try
+        {
+            Integer n = new Integer( Integer.parseInt( s ) + 1 );
+            if ( n.toString().length() < s.length() )
+            {
+                // String was left-padded with zeros
+                return StringUtils.leftPad( n.toString(), s.length(), "0" );
+            }
+            return n.toString();
+        }
+        catch ( NumberFormatException e )
+        {
+            return null;
+        }
+    }
+    
+    public String getSnapshotVersionString() 
+    {
+        return getVersionString(this, SNAPSHOT_IDENTIFIER, 
StringUtils.defaultString( this.buildSeparator, "-" ) );
+    }
+    
+    public String getReleaseVersionString()
+    {
+        return getVersionString( this, null, null );
+    }
+
+    public String getVersionString()
+    {
+        return getVersionString( this, this.buildSpecifier, 
this.buildSeparator );
+    }
+
+    protected static String getVersionString( DefaultVersionInfo info, String 
buildSpecifier, String buildSeparator )
+    {
+        StringBuffer sb = new StringBuffer();
+
+        if ( StringUtils.isNotEmpty( info.component ) )
+        {
+            sb.append( info.component );
+        }
+
+        if ( info.digits != null )
+        {
+            sb.append( StringUtils.defaultString( info.digitSeparator ) );
+            sb.append( joinDigitString( info.digits ) );
+        }
+
+        if ( StringUtils.isNotEmpty( info.annotation ) )
+        {
+            sb.append( StringUtils.defaultString( info.annotationSeparator ) );
+            sb.append( info.annotation );
+        }
+
+        if ( StringUtils.isNotEmpty( info.annotationRevision ) )
+        {
+            if ( StringUtils.isEmpty( info.annotation ) )
+            {
+                sb.append( StringUtils.defaultString( info.annotationSeparator 
) );
+            }
+            else
+            {
+                sb.append( StringUtils.defaultString( 
info.annotationRevSeparator ) );
+            }
+            sb.append( info.annotationRevision );
+        }
+
+        if ( StringUtils.isNotEmpty( buildSpecifier ) )
+        {
+            sb.append( StringUtils.defaultString( buildSeparator ) );
+            sb.append( buildSpecifier );
+        }
+
+        return sb.toString();
+    }
+    
+    /** Simply joins the items in the list with "." period
+     * 
+     * @param digits
+     * @return
+     */
+    protected static String joinDigitString( List digits )
+    {
+        if ( digits == null )
+        {
+            return null;
+        }
+
+        return StringUtils.join( digits.iterator(), DIGIT_SEPARATOR_STRING );
+    }
+
+    /** Splits the string on "." and returns a list 
+     * containing each digit.
+     * 
+     * @param strDigits
+     * @return
+     */
+    protected List parseDigits( String strDigits )
+    {
+        if ( StringUtils.isEmpty( strDigits ) )
+        {
+            return null;
+        }
+
+        String[] strings = StringUtils.split( strDigits, 
DIGIT_SEPARATOR_STRING );
+        return Arrays.asList( strings );
+    }
+
+    //--------------------------------------------------
+    // Getters & Setters
+    //--------------------------------------------------
+
+    private String nullIfEmpty( String s )
+    {
+        return ( StringUtils.isEmpty( s ) ) ? null : s;
+    }
+
+    public String getAnnotation()
+    {
+        return annotation;
+    }
+
+    protected void setAnnotation( String annotation )
+    {
+        this.annotation = nullIfEmpty( annotation );
+    }
+
+    public String getAnnotationRevision()
+    {
+        return annotationRevision;
+    }
+
+    protected void setAnnotationRevision( String annotationRevision )
+    {
+        this.annotationRevision = nullIfEmpty( annotationRevision );
+    }
+
+    public String getComponent()
+    {
+        return component;
+    }
+
+    protected void setComponent( String component )
+    {
+        this.component = nullIfEmpty( component );
+    }
+
+    public List getDigits()
+    {
+        return digits;
+    }
+
+    protected void setDigits( List digits )
+    {
+        this.digits = digits;
+    }
+
+    public String getBuildSpecifier()
+    {
+        return buildSpecifier;
+    }
+
+    protected void setBuildSpecifier( String buildSpecifier )
+    {
+        this.buildSpecifier = nullIfEmpty( buildSpecifier );
+    }
+
+    public List getAnnotationOrder()
+    {
+        return annotationOrder;
+    }
+
+    protected void setAnnotationOrder( List annotationOrder )
+    {
+        this.annotationOrder = annotationOrder;
+    }
+
+}

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/DefaultVersionInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/DefaultVersionInfo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionInfo.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionInfo.java?rev=345255&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionInfo.java
 (added)
+++ 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionInfo.java
 Thu Nov 17 06:58:21 2005
@@ -0,0 +1,35 @@
+package org.apache.maven.plugins.release.versions;
+
+public interface VersionInfo
+    extends Comparable
+{
+    /** Returns a string representing the version without modification.
+     * 
+     * @return
+     */
+    public String getVersionString();
+
+    /** Returns a string representing the version with a snapshot specification
+     * 
+     * @return
+     */
+    public String getSnapshotVersionString();
+
+    /** Returns a string representing the version without a snapshot 
specification.
+     * 
+     * @return
+     */
+    public String getReleaseVersionString();
+
+    /** Returns a [EMAIL PROTECTED] VersionInfo} object which represents the 
next version of this object.
+     * 
+     * @return
+     */
+    public VersionInfo getNextVersion();
+
+    /** Returns whether this represents a snapshot version. ("xxx-SNAPSHOT");
+     * 
+     * @return
+     */
+    public boolean isSnapshot();
+}

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionInfo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionParseException.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionParseException.java?rev=345255&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionParseException.java
 (added)
+++ 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionParseException.java
 Thu Nov 17 06:58:21 2005
@@ -0,0 +1,25 @@
+package org.apache.maven.plugins.release.versions;
+
+public class VersionParseException
+    extends Exception
+{
+    public VersionParseException()
+    {
+        super();
+    }
+
+    public VersionParseException( String message )
+    {
+        super( message );
+    }
+
+    public VersionParseException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public VersionParseException( Throwable cause )
+    {
+        super( cause );
+    }
+}

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionParseException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/versions/VersionParseException.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/versions/DefaultVersionInfoTest.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/versions/DefaultVersionInfoTest.java?rev=345255&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/versions/DefaultVersionInfoTest.java
 (added)
+++ 
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/versions/DefaultVersionInfoTest.java
 Thu Nov 17 06:58:21 2005
@@ -0,0 +1,272 @@
+package org.apache.maven.plugins.release.versions;
+
+import org.codehaus.plexus.PlexusTestCase;
+
+public class DefaultVersionInfoTest
+    extends PlexusTestCase
+{
+    public void testParse() 
+        throws Exception
+    {
+        testParse( "1.0", null, "1.0", null, null, null );
+    }
+
+    public void testParseWithBadVersion()
+        throws Exception
+    {
+        try
+        {
+            testParse( "SNAPSHOT", null, null, null, null, "SNAPSHOT" );
+            fail( "version is incorrect, must fail." );
+        }
+        catch( VersionParseException e )
+        {
+        }
+    }
+        
+    public void testParseMultiDigit() 
+        throws Exception
+    {        
+        testParse( "99.99", null, "99.99", null, null, null );
+        testParse( "990.990.990", null, "990.990.990", null, null, null );
+    }
+    
+    public void testParseComponent() 
+        throws Exception
+    {        
+        testParse( "my-component-99.99",     "my-component", "99.99",    null, 
null, null );
+        testParse( "my-component_99.99",     "my-component", "99.99",    null, 
null, null );
+        testParse( "my-component1.2.3",      "my-component", "1.2.3",    null, 
null, null );
+        testParse( "my-component11.22.33",   "my-component", "11.22.33", null, 
null, null );
+    }
+    
+    public void testParseSnapshotVersion() 
+        throws Exception
+    {
+        testParse( "1.0-beta-4-SNAPSHOT", null, "1.0", "beta", "4", "SNAPSHOT" 
);        
+        testParse( "1.0-beta-4_SNAPSHOT", null, "1.0", "beta", "4", "SNAPSHOT" 
);
+    }
+    
+    public void testParseAnnotationVersion() 
+        throws Exception
+    {
+        testParse( "1.0-beta-4-SNAPSHOT",   null, "1.0",    "beta", "4",    
"SNAPSHOT" );
+        testParse( "1.0-beta-4",            null, "1.0",    "beta", "4",    
null );
+        testParse( "1.2.3-beta-99",         null, "1.2.3",  "beta", "99",   
null );
+        testParse( "1.2.3-beta99",          null, "1.2.3",  "beta", "99",   
null );
+        testParse( "1.2.3-beta99-SNAPSHOT", null, "1.2.3",  "beta", "99",   
"SNAPSHOT" );
+        testParse( "1.2.3-RC4",             null, "1.2.3",  "RC",   "4",    
null );
+    }
+    
+    public void testParseSeparators() 
+        throws Exception
+    {
+        testParse("log4j-1.2.9-beta-9-SNAPSHOT", "log4j", "1.2.9", "beta", 
"9", "SNAPSHOT");
+        testParse("log4j1.2.9beta9SNAPSHOT", "log4j", "1.2.9", "beta", "9", 
"SNAPSHOT");
+        testParse("log4j1.2.9beta-9SNAPSHOT", "log4j", "1.2.9", "beta", "9", 
"SNAPSHOT");
+        testParse("log4j_1.2.9_beta_9_SNAPSHOT", "log4j", "1.2.9", "beta", 
"9", "SNAPSHOT");
+    }
+    
+    public void testParseAnnotationNoVersionButSnapshot() 
+        throws Exception
+    {
+        testParse( "1.0-beta-SNAPSHOT",   null, "1.0",   "beta", null,   
"SNAPSHOT" );        
+        testParse( "1.2.3-beta99",        null, "1.2.3", "beta", "99",   null 
);
+        testParse( "1.2.3-RC4-SNAPSHOT",  null, "1.2.3", "RC",   "4",    
"SNAPSHOT" );
+    }
+    
+    public void testParseAnnotationVersionWithRevision() 
+        throws Exception
+    {
+        testParse( "1.0-beta-4-SNAPSHOT",   null, "1.0",   "beta", "4",  
"SNAPSHOT" );
+        testParse( "1.0-beta-4",            null, "1.0",   "beta", "4",  null 
);
+        testParse( "1.2.3-beta-99",         null, "1.2.3", "beta", "99", null 
);
+        testParse( "1.2.3-beta99",          null, "1.2.3", "beta", "99", null 
);
+        testParse( "1.2.3-RC4",             null, "1.2.3", "RC",   "4",  null 
);
+
+        testParse( "mycomponent-1.2.3-RC4", "mycomponent", "1.2.3", "RC", "4", 
 null );
+        testParse( "mycomponent-1.2.3-RC4", "mycomponent", "1.2.3", "RC", "4", 
 null );
+        testParse( "log4j-1.2.9",           "log4j",       "1.2.9", null, 
null, null );
+    }
+    
+    public void testParseLeadingZeros() 
+        throws Exception
+    {
+        testParse( "1.01-beta-04-SNAPSHOT",   null, "1.01",   "beta", "04",  
"SNAPSHOT" );        
+        testParse( "01.01.001-beta-04-SNAPSHOT",   null, "01.01.001",   
"beta", "04",  "SNAPSHOT" );
+    }
+    
+    public void testParseBuildNumber() 
+        throws Exception
+    {        
+        testParse( 
"plexus-logging-provider-test-1.0-alpha-2-20051013.095555-2", 
+                   "plexus-logging-provider-test", "1.0", "alpha", "2", 
"20051013.095555-2" );
+    }
+    
+    public void testNextVersion() 
+        throws Exception
+    {
+        testNextVersion( "1.01",  "1.02" );
+        testNextVersion( "1.9",   "1.10" );
+        testNextVersion( "1.09",  "1.10" );
+        testNextVersion( "1.009", "1.010" );
+        
+        testNextVersion( "1.99", "1.100" );
+    }
+    
+    public void testNextAnnotationRevision() 
+        throws Exception
+    {
+        testNextVersion( "1.01-beta-04", "1.01-beta-05" );
+        testNextVersion( "1.01-beta-04-SNAPSHOT", "1.01-beta-05-SNAPSHOT" );
+        testNextVersion( "9.99.999-beta-9-SNAPSHOT", 
"9.99.999-beta-10-SNAPSHOT" );
+        testNextVersion( "9.99.999-beta-09-SNAPSHOT", 
"9.99.999-beta-10-SNAPSHOT" );
+        testNextVersion( "9.99.999-beta-009-SNAPSHOT", 
"9.99.999-beta-010-SNAPSHOT" );
+        testNextVersion( "9.99.999-beta9-SNAPSHOT", "9.99.999-beta10-SNAPSHOT" 
);        
+    }
+    
+    public void testCompareToDigitsOnly() 
+        throws Exception
+    {
+        testVersionLessThanVersion( "1.01", "1.02" );
+        testVersionLessThanVersion( "1.01", "1.00009" );
+        testVersionLessThanVersion( "1.01.99", "1.0002" );
+        testVersionLessThanVersion( "1.01", "1.01.01" );
+        
+        testVersionEqualVersion( "1.01", "1.1" );
+        testVersionEqualVersion( "1.01", "1.01" );
+        testVersionEqualVersion( "1.01", "1.001" );
+        
+    }
+    
+    public void testCompareToAnnotation() 
+        throws Exception
+    {
+        testVersionLessThanVersion( "1.01-alpha",   "1.01" );
+        testVersionLessThanVersion( "1.01-alpha",   "1.01-beta" );
+        testVersionLessThanVersion( "1.01-beta",    "1.01-RC1");
+        testVersionLessThanVersion( "1.01-beta",    "1.01-RC" );
+        testVersionLessThanVersion( "1.01-alpha-4", "1.01.1-beta-1" );
+        testVersionLessThanVersion( "1.01-alpha-4-SNAPSHOT", "1.01-beta");
+        
+        testVersionEqualVersion( "1.01-alpha-4-SNAPSHOT", 
"1.01-alpha-004-SNAPSHOT");        
+    }
+    
+    public void testCompareToAnnotationRevision() 
+        throws Exception
+    {
+        testVersionLessThanVersion( "1.01-beta-04-SNAPSHOT",    
"1.01-beta-05-SNAPSHOT" );
+        testVersionLessThanVersion( "1.01-beta-0004-SNAPSHOT",  
"1.01-beta-5-SNAPSHOT" );
+        testVersionLessThanVersion( "1.01-beta-4-SNAPSHOT",     
"1.01.1-beta-4-SNAPSHOT" );
+        
+        testVersionEqualVersion( "1.01-beta-4-SNAPSHOT", 
"1.01-beta-0004-SNAPSHOT");
+        testVersionEqualVersion( "1.01-beta4",           "1.01-beta-0004");    
    
+        
+        testVersionLessThanVersion( "1.01-beta9", "1.01-RC1");
+        testVersionLessThanVersion( "1.01-beta9", "1.01-RC-1");
+    }
+    
+    public void testCompareToBuildSpecifier() 
+        throws Exception
+    {
+        testVersionLessThanVersion( "1.01-SNAPSHOT",         "1.01" );        
+        testVersionLessThanVersion( "1.01-beta-04-SNAPSHOT", "1.01-beta-04" );
+        
+        testVersionEqualVersion( "1.01-beta-04-SNAPSHOT", 
"1.01-beta-04-SNAPSHOT" );
+        
+        testVersionLessThanVersion( "1.01-beta-04-20051112.134500-2", 
"1.01-beta-04-SNAPSHOT");
+        testVersionLessThanVersion( "1.01-beta-04-20051112.134500-1", 
"1.01-beta-04-20051112.134500-2" );
+        testVersionLessThanVersion( "1.01-beta-04-20051112.134500-1", 
"1.01-beta-04-20051113.134500-1" );
+    }
+    
+    public void testGetReleaseVersion()
+        throws Exception
+    {
+        testGetReleaseVersion( "1.01",          "1.01" );
+        testGetReleaseVersion( "1.01-beta",     "1.01-beta" );
+        testGetReleaseVersion( "1.01-beta-04",  "1.01-beta-04" );
+        
+        testGetReleaseVersion( "1.01-beta-04-SNAPSHOT",          
"1.01-beta-04" );
+        testGetReleaseVersion( "1.01-beta-04-20051112.134500-1", 
"1.01-beta-04" );        
+    }
+    
+    public void testGetSnapshotVersion()
+        throws Exception
+    {
+        testGetSnapshotVersion( "1.01",          "1.01-SNAPSHOT" );
+        testGetSnapshotVersion( "1.01-beta",     "1.01-beta-SNAPSHOT" );
+        testGetSnapshotVersion( "1.01-beta-04",  "1.01-beta-04-SNAPSHOT" );
+        
+        testGetSnapshotVersion( "1.01-beta-04-SNAPSHOT",          
"1.01-beta-04-SNAPSHOT" );
+        testGetSnapshotVersion( "1.01-beta-04-20051112.134500-1", 
"1.01-beta-04-SNAPSHOT" );        
+        testGetSnapshotVersion( "1.01-beta-04_20051112.134500-1", 
"1.01-beta-04_SNAPSHOT" );        
+    }
+    
+    private void testGetReleaseVersion(String strVersion, String expected)
+        throws Exception
+    {
+        DefaultVersionInfo v = new DefaultVersionInfo( strVersion );
+        assertEquals(expected, v.getReleaseVersionString());
+    }
+    
+    private void testGetSnapshotVersion(String strVersion, String expected)
+        throws Exception
+    {
+        DefaultVersionInfo v = new DefaultVersionInfo( strVersion );
+        assertEquals(expected, v.getSnapshotVersionString());
+    }
+    
+    private void testParse( String strVersion, String component, String 
digits, String annotation,
+                           String annotationRevision, String buildSpecifier )
+        throws Exception
+    {
+        DefaultVersionInfo v = new DefaultVersionInfo( strVersion );
+
+        assertEquals( strVersion, v.getVersionString() );
+        assertEquals( component, v.getComponent() );
+        assertEquals( digits, DefaultVersionInfo.joinDigitString( 
v.getDigits() ) );
+        assertEquals( annotation, v.getAnnotation() );
+        assertEquals( annotationRevision, v.getAnnotationRevision() );
+        assertEquals( buildSpecifier, v.getBuildSpecifier() );
+    }
+
+    private void testNextVersion( String strVersion, String nextVersion )
+        throws Exception
+    {
+        DefaultVersionInfo v = new DefaultVersionInfo( strVersion );
+        VersionInfo nextV = v.getNextVersion();
+
+        assertNotNull( nextV );
+        assertEquals( nextVersion, nextV.getVersionString() );
+    }
+
+    private void testVersionLessThanVersion( String lesserVersion, String 
greaterVersion )
+        throws Exception
+    {
+        testCompareTo( lesserVersion, greaterVersion, false );
+
+    }
+    
+    private void testVersionEqualVersion( String version1, String version2 )
+        throws Exception
+    {
+        testCompareTo( version1, version2, true );
+        
+    }
+
+    private void testCompareTo( String lesserVersion, String greaterVersion, 
boolean equal )
+        throws Exception
+    {
+        DefaultVersionInfo lesserV = new DefaultVersionInfo( lesserVersion );
+        DefaultVersionInfo greaterV = new DefaultVersionInfo( greaterVersion );
+
+        if ( equal )
+        {
+            assertEquals( lesserV.compareTo( greaterV ), 0 );
+        }
+        else
+        {
+            assertTrue( lesserV.compareTo( greaterV ) < 0 );
+        }
+    }
+}

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/versions/DefaultVersionInfoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/versions/DefaultVersionInfoTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"


Reply via email to