PR: MNG-505

if a version doesn't match the format, revert to string comparison

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@219777 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-07-19 21:19:26 +00:00
parent 76d971b4ba
commit 50eb5f8fdc
2 changed files with 29 additions and 5 deletions

View File

@ -186,14 +186,24 @@ public class DefaultArtifactVersion
else
{
StringTokenizer tok = new StringTokenizer( part1, "." );
majorVersion = Integer.valueOf( tok.nextToken() );
if ( tok.hasMoreTokens() )
try
{
minorVersion = Integer.valueOf( tok.nextToken() );
majorVersion = Integer.valueOf( tok.nextToken() );
if ( tok.hasMoreTokens() )
{
minorVersion = Integer.valueOf( tok.nextToken() );
}
if ( tok.hasMoreTokens() )
{
incrementalVersion = Integer.valueOf( tok.nextToken() );
}
}
if ( tok.hasMoreTokens() )
catch ( NumberFormatException e )
{
incrementalVersion = Integer.valueOf( tok.nextToken() );
// qualifier is the whole version, including "-"
qualifier = version;
majorVersion = null;
minorVersion = null;
}
}
}

View File

@ -84,6 +84,20 @@ public class DefaultArtifactVersionTest
assertEquals( "check incremental version", 0, version.getIncrementalVersion() );
assertEquals( "check build number", 0, version.getBuildNumber() );
assertEquals( "check qualifier", "RELEASE", version.getQualifier() );
version = new DefaultArtifactVersion( "1.0.1b" );
assertEquals( "check major version", 0, version.getMajorVersion() );
assertEquals( "check minor version", 0, version.getMinorVersion() );
assertEquals( "check incremental version", 0, version.getIncrementalVersion() );
assertEquals( "check build number", 0, version.getBuildNumber() );
assertEquals( "check qualifier", "1.0.1b", version.getQualifier() );
version = new DefaultArtifactVersion( "1.0RC2" );
assertEquals( "check major version", 0, version.getMajorVersion() );
assertEquals( "check minor version", 0, version.getMinorVersion() );
assertEquals( "check incremental version", 0, version.getIncrementalVersion() );
assertEquals( "check build number", 0, version.getBuildNumber() );
assertEquals( "check qualifier", "1.0RC2", version.getQualifier() );
}
public void testVersionComparing()