[MNG-4751] Snapshot version not resolved for version range

o Reverted fix for MNG-3092 until we have a more robust solution in place

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@997380 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-09-15 16:08:51 +00:00
parent 8a3c4a0d77
commit 122d51960a
4 changed files with 9 additions and 48 deletions

View File

@ -23,7 +23,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@ -42,7 +41,6 @@ import org.sonatype.aether.util.version.GenericVersionScheme;
import org.sonatype.aether.version.InvalidVersionSpecificationException;
import org.sonatype.aether.version.Version;
import org.sonatype.aether.version.VersionConstraint;
import org.sonatype.aether.version.VersionRange;
import org.sonatype.aether.version.VersionScheme;
import org.sonatype.aether.impl.MetadataResolver;
import org.sonatype.aether.impl.VersionRangeResolver;
@ -125,8 +123,7 @@ public class DefaultVersionRangeResolver
}
else
{
Map<String, ArtifactRepository> versionIndex =
getVersions( session, result, request, getNature( session, versionConstraint.getRanges() ) );
Map<String, ArtifactRepository> versionIndex = getVersions( session, result, request );
List<Version> versions = new ArrayList<Version>();
for ( Map.Entry<String, ArtifactRepository> v : versionIndex.entrySet() )
@ -154,13 +151,13 @@ public class DefaultVersionRangeResolver
}
private Map<String, ArtifactRepository> getVersions( RepositorySystemSession session, VersionRangeResult result,
VersionRangeRequest request, Metadata.Nature nature )
VersionRangeRequest request )
{
Map<String, ArtifactRepository> versionIndex = new HashMap<String, ArtifactRepository>();
Metadata metadata =
new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(),
MAVEN_METADATA_XML, nature );
MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
List<MetadataRequest> metadataRequests = new ArrayList<MetadataRequest>( request.getRepositories().size() );
for ( RemoteRepository repository : request.getRepositories() )
@ -212,18 +209,6 @@ public class DefaultVersionRangeResolver
return versionIndex;
}
private Metadata.Nature getNature( RepositorySystemSession session, Collection<VersionRange> ranges )
{
for ( VersionRange range : ranges )
{
if ( range.acceptsSnapshots() )
{
return Metadata.Nature.RELEASE_OR_SNAPSHOT;
}
}
return Metadata.Nature.RELEASE;
}
private Versioning readVersions( RepositorySystemSession session, Metadata metadata, VersionRangeResult result )
{
Versioning versioning = null;

View File

@ -19,8 +19,6 @@ package org.apache.maven.artifact.versioning;
* under the License.
*/
import org.apache.maven.artifact.Artifact;
/**
* Describes a restriction in versioning.
*
@ -70,17 +68,10 @@ public class Restriction
public boolean containsVersion( ArtifactVersion version )
{
boolean snapshot = isSnapshot( version );
if ( lowerBound != null )
{
int comparison = lowerBound.compareTo( version );
if ( snapshot && comparison == 0 )
{
return true;
}
if ( ( comparison == 0 ) && !lowerBoundInclusive )
{
return false;
@ -94,11 +85,6 @@ public class Restriction
{
int comparison = upperBound.compareTo( version );
if ( snapshot && comparison == 0 )
{
return true;
}
if ( ( comparison == 0 ) && !upperBoundInclusive )
{
return false;
@ -109,19 +95,9 @@ public class Restriction
}
}
if ( lowerBound != null || upperBound != null )
{
return !snapshot;
}
return true;
}
private boolean isSnapshot( ArtifactVersion version )
{
return Artifact.SNAPSHOT_VERSION.equals( version.getQualifier() );
}
@Override
public int hashCode()
{

View File

@ -655,13 +655,13 @@ public class VersionRangeTest
assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
}
public void testReleaseRangeBoundsCannotContainSnapshots()
public void testReleaseRangeBoundsContainsSnapshots()
throws InvalidVersionSpecificationException
{
VersionRange range = VersionRange.createFromVersionSpec( "[1.0,1.2]" );
assertFalse( range.containsVersion( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ) );
assertFalse( range.containsVersion( new DefaultArtifactVersion( "1.2-SNAPSHOT" ) ) );
assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ) );
assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.2-SNAPSHOT" ) ) );
}
public void testSnapshotRangeBoundsCanContainSnapshots()
@ -669,13 +669,13 @@ public class VersionRangeTest
{
VersionRange range = VersionRange.createFromVersionSpec( "[1.0,1.2-SNAPSHOT]" );
assertFalse( range.containsVersion( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ) );
assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ) );
assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.2-SNAPSHOT" ) ) );
range = VersionRange.createFromVersionSpec( "[1.0-SNAPSHOT,1.2]" );
assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.0-SNAPSHOT" ) ) );
assertFalse( range.containsVersion( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ) );
assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ) );
}
public void testSnapshotSoftVersionCanContainSnapshot()

View File

@ -50,7 +50,7 @@
<cipherVersion>1.4</cipherVersion>
<modelloVersion>1.4</modelloVersion>
<jxpathVersion>1.3</jxpathVersion>
<aetherVersion>1.3</aetherVersion>
<aetherVersion>1.4</aetherVersion>
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
</properties>