additional rule about SNAPSHOTs

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@219475 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-07-18 11:59:56 +00:00
parent 640667a6a2
commit 148aac1ba9
2 changed files with 28 additions and 1 deletions

View File

@ -65,7 +65,22 @@ public class DefaultArtifactVersion
{
if ( otherVersion.qualifier != null )
{
result = qualifier.compareTo( otherVersion.qualifier );
if ( qualifier.length() > otherVersion.qualifier.length() &&
qualifier.startsWith( otherVersion.qualifier ) )
{
// here, the longer one that otherwise match is considered older
result = -1;
}
else if ( qualifier.length() < otherVersion.qualifier.length() &&
otherVersion.qualifier.startsWith( qualifier ) )
{
// here, the longer one that otherwise match is considered older
result = 1;
}
else
{
result = qualifier.compareTo( otherVersion.qualifier );
}
}
else
{

View File

@ -137,6 +137,18 @@ public class DefaultArtifactVersionTest
version = new DefaultArtifactVersion( "1.0-SNAPSHOT" );
assertTrue( version.compareTo( new DefaultArtifactVersion( "1.0-beta-1" ) ) < 0 );
version = new DefaultArtifactVersion( "1.0-SNAPSHOT" );
assertTrue( version.compareTo( new DefaultArtifactVersion( "1.0" ) ) < 0 );
version = new DefaultArtifactVersion( "1.0" );
assertTrue( version.compareTo( new DefaultArtifactVersion( "1.0-SNAPSHOT" ) ) > 0 );
version = new DefaultArtifactVersion( "1.0-alpha-1-SNAPSHOT" );
assertTrue( version.compareTo( new DefaultArtifactVersion( "1.0-alpha-1" ) ) < 0 );
version = new DefaultArtifactVersion( "1.0-alpha-1" );
assertTrue( version.compareTo( new DefaultArtifactVersion( "1.0-alpha-1-SNAPSHOT" ) ) > 0 );
version = new DefaultArtifactVersion( "1.0" );
assertTrue( version.compareTo( new DefaultArtifactVersion( "1.0-1" ) ) < 0 );