mirror of https://github.com/apache/maven.git
[MNG-3626] Small change to artifact version parsing.
Applied patch inspired by patch submitted by Paul Gier. - Substantially rewrote test case to match current testing style - Changed the patch to ensure that 4 segment number only version number are not affected... would be nice to pick them up but holding that change back for now
This commit is contained in:
parent
61dbaabfbd
commit
5cf05463a4
|
@ -20,6 +20,7 @@ package org.apache.maven.artifact.versioning;
|
|||
*/
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Default implementation of artifact versioning.
|
||||
|
@ -174,7 +175,8 @@ public class DefaultArtifactVersion
|
|||
}
|
||||
if ( tok.hasMoreTokens() )
|
||||
{
|
||||
fallback = true;
|
||||
qualifier = tok.nextToken();
|
||||
fallback = Pattern.compile("\\d+").matcher( qualifier ).matches();
|
||||
}
|
||||
|
||||
// string tokenzier won't detect these and ignores them
|
||||
|
@ -213,34 +215,6 @@ public class DefaultArtifactVersion
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if ( majorVersion != null )
|
||||
{
|
||||
buf.append( majorVersion );
|
||||
}
|
||||
if ( minorVersion != null )
|
||||
{
|
||||
buf.append( "." );
|
||||
buf.append( minorVersion );
|
||||
}
|
||||
if ( incrementalVersion != null )
|
||||
{
|
||||
buf.append( "." );
|
||||
buf.append( incrementalVersion );
|
||||
}
|
||||
if ( buildNumber != null )
|
||||
{
|
||||
buf.append( "-" );
|
||||
buf.append( buildNumber );
|
||||
}
|
||||
else if ( qualifier != null )
|
||||
{
|
||||
if ( buf.length() > 0 )
|
||||
{
|
||||
buf.append( "-" );
|
||||
}
|
||||
buf.append( qualifier );
|
||||
}
|
||||
return buf.toString();
|
||||
return comparable.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,8 @@ public class DefaultArtifactVersionTest
|
|||
checkVersionParsing( "1.0.1b" , 0, 0, 0, 0, "1.0.1b" );
|
||||
checkVersionParsing( "1.0M2" , 0, 0, 0, 0, "1.0M2" );
|
||||
checkVersionParsing( "1.0RC2" , 0, 0, 0, 0, "1.0RC2" );
|
||||
checkVersionParsing( "1.1.2.beta1", 1, 1, 2, 0, "beta1" );
|
||||
checkVersionParsing( "1.7.3.beta1", 1, 7, 3, 0, "beta1" );
|
||||
checkVersionParsing( "1.7.3.0" , 0, 0, 0, 0, "1.7.3.0" );
|
||||
checkVersionParsing( "1.7.3.0-1" , 0, 0, 0, 0, "1.7.3.0-1" );
|
||||
checkVersionParsing( "PATCH-1193602" , 0, 0, 0, 0, "PATCH-1193602" );
|
||||
|
@ -97,6 +99,10 @@ public class DefaultArtifactVersionTest
|
|||
assertVersionOlder( "1.0.0", "1.1" );
|
||||
assertVersionOlder( "1.1", "1.2.0" );
|
||||
|
||||
assertVersionOlder( "1.1.2.alpha1", "1.1.2" );
|
||||
assertVersionOlder( "1.1.2.alpha1", "1.1.2.beta1" );
|
||||
assertVersionOlder( "1.1.2.beta1", "1.2" );
|
||||
|
||||
assertVersionOlder( "1.0-alpha-1", "1.0" );
|
||||
assertVersionOlder( "1.0-alpha-1", "1.0-alpha-2" );
|
||||
assertVersionOlder( "1.0-alpha-2", "1.0-alpha-15" );
|
||||
|
|
Loading…
Reference in New Issue