diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java index a84bf7cc53..462df4a949 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java @@ -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 versionIndex = - getVersions( session, result, request, getNature( session, versionConstraint.getRanges() ) ); + Map versionIndex = getVersions( session, result, request ); List versions = new ArrayList(); for ( Map.Entry v : versionIndex.entrySet() ) @@ -154,13 +151,13 @@ public class DefaultVersionRangeResolver } private Map getVersions( RepositorySystemSession session, VersionRangeResult result, - VersionRangeRequest request, Metadata.Nature nature ) + VersionRangeRequest request ) { Map versionIndex = new HashMap(); Metadata metadata = new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), - MAVEN_METADATA_XML, nature ); + MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT ); List metadataRequests = new ArrayList( request.getRepositories().size() ); for ( RemoteRepository repository : request.getRepositories() ) @@ -212,18 +209,6 @@ public class DefaultVersionRangeResolver return versionIndex; } - private Metadata.Nature getNature( RepositorySystemSession session, Collection 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; diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java index f90fcd73d7..cb0968e22c 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java @@ -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() { diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java index 485ba33b24..772939b0fc 100644 --- a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java @@ -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() diff --git a/pom.xml b/pom.xml index 6318b7b3fc..ee77717c05 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ 1.4 1.4 1.3 - 1.3 + 1.4 true