o Fixed handling of version ranges

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@784438 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-06-13 17:32:12 +00:00
parent 0a4f0ebb35
commit e743f23a6a
2 changed files with 18 additions and 9 deletions

View File

@ -137,7 +137,10 @@ public final class ArtifactUtils
clone.setFile( artifact.getFile() ); clone.setFile( artifact.getFile() );
clone.setAvailableVersions( copyList( artifact.getAvailableVersions() ) ); clone.setAvailableVersions( copyList( artifact.getAvailableVersions() ) );
if ( artifact.getVersion() != null )
{
clone.setBaseVersion( artifact.getBaseVersion() ); clone.setBaseVersion( artifact.getBaseVersion() );
}
clone.setDependencyFilter( artifact.getDependencyFilter() ); clone.setDependencyFilter( artifact.getDependencyFilter() );
clone.setDependencyTrail( copyList( artifact.getDependencyTrail() ) ); clone.setDependencyTrail( copyList( artifact.getDependencyTrail() ) );
clone.setDownloadUrl( artifact.getDownloadUrl() ); clone.setDownloadUrl( artifact.getDownloadUrl() );

View File

@ -39,6 +39,8 @@ import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.Exclusion; import org.apache.maven.model.Exclusion;
import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.DefaultProjectBuildingRequest;
@ -149,17 +151,21 @@ public class MavenMetadataSource
{ {
Artifact dependencyArtifact; Artifact dependencyArtifact;
//TODO: deal with this in a unified way, probably just looking at the dependency. VersionRange versionRange;
if ( d.getClassifier() != null ) try
{ {
dependencyArtifact = repositorySystem.createArtifactWithClassifier( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getType(), d.getClassifier() ); versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
} }
else catch ( InvalidVersionSpecificationException e )
{ {
dependencyArtifact = repositorySystem.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), effectiveScope, d.getType() ); throw new ArtifactMetadataRetrievalException( "Invalid version for dependency "
+ d.getManagementKey() + ": " + e.getMessage(), e, pomArtifact );
} }
dependencyArtifact.setScope( effectiveScope ); dependencyArtifact =
repositorySystem.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange,
d.getType(), d.getClassifier(), effectiveScope,
d.isOptional() );
if ( dependencyFilter == null || dependencyFilter.include( dependencyArtifact ) ) if ( dependencyFilter == null || dependencyFilter.include( dependencyArtifact ) )
{ {
@ -252,7 +258,7 @@ public class MavenMetadataSource
} }
catch ( RepositoryMetadataResolutionException e ) catch ( RepositoryMetadataResolutionException e )
{ {
throw new ArtifactMetadataRetrievalException( e.getMessage(), e ); throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
} }
return retrieveAvailableVersionsFromMetadata( metadata.getMetadata() ); return retrieveAvailableVersionsFromMetadata( metadata.getMetadata() );
@ -268,7 +274,7 @@ public class MavenMetadataSource
} }
catch ( RepositoryMetadataResolutionException e ) catch ( RepositoryMetadataResolutionException e )
{ {
throw new ArtifactMetadataRetrievalException( e.getMessage(), e ); throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
} }
return retrieveAvailableVersionsFromMetadata( metadata.getMetadata() ); return retrieveAvailableVersionsFromMetadata( metadata.getMetadata() );