mirror of https://github.com/apache/maven.git
[MNG-7106] Accept same lower and upper bound in version spec string (#825)
This commit is contained in:
parent
3f90e7028e
commit
78edd43122
|
@ -211,10 +211,6 @@ public class VersionRange
|
|||
{
|
||||
String lowerBound = process.substring( 0, index ).trim();
|
||||
String upperBound = process.substring( index + 1 ).trim();
|
||||
if ( lowerBound.equals( upperBound ) )
|
||||
{
|
||||
throw new InvalidVersionSpecificationException( "Range cannot have identical boundaries: " + spec );
|
||||
}
|
||||
|
||||
ArtifactVersion lowerVersion = null;
|
||||
if ( lowerBound.length() > 0 )
|
||||
|
@ -227,9 +223,13 @@ public class VersionRange
|
|||
upperVersion = new DefaultArtifactVersion( upperBound );
|
||||
}
|
||||
|
||||
if ( upperVersion != null && lowerVersion != null && upperVersion.compareTo( lowerVersion ) < 0 )
|
||||
if ( upperVersion != null && lowerVersion != null )
|
||||
{
|
||||
throw new InvalidVersionSpecificationException( "Range defies version ordering: " + spec );
|
||||
int result = upperVersion.compareTo( lowerVersion );
|
||||
if ( result < 0 || ( result == 0 && ( !lowerBoundInclusive || !upperBoundInclusive ) ) )
|
||||
{
|
||||
throw new InvalidVersionSpecificationException( "Range defies version ordering: " + spec );
|
||||
}
|
||||
}
|
||||
|
||||
restriction = new Restriction( lowerVersion, lowerBoundInclusive, upperVersion, upperBoundInclusive );
|
||||
|
|
|
@ -160,6 +160,14 @@ public class VersionRangeTest
|
|||
assertTrue( range.containsVersion( new DefaultArtifactVersion( "5.0.9.0" ) ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSameUpperAndLowerBoundRoundtrip() throws InvalidVersionSpecificationException
|
||||
{
|
||||
VersionRange range = VersionRange.createFromVersionSpec( "[1.0]" );
|
||||
VersionRange range2 = VersionRange.createFromVersionSpec( range.toString() );
|
||||
assertEquals( range, range2 );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidRanges()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue