mirror of https://github.com/apache/maven.git
[MARTIFACT-6] The deployer should detect previous deployments of the same version and die
This corrects the test case and implementation, utilising the previous changes made to ensure mirrors and other repository metadata are not consulted for metadata git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@669227 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5be7ffdd23
commit
825448f10e
|
@ -33,6 +33,7 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutio
|
|||
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
|
||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
|
@ -441,8 +442,8 @@ public class MavenMetadataSource
|
|||
return projectArtifacts;
|
||||
}
|
||||
|
||||
public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
|
||||
List remoteRepositories )
|
||||
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
|
||||
|
@ -455,21 +456,43 @@ public class MavenMetadataSource
|
|||
throw new ArtifactMetadataRetrievalException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
List versions;
|
||||
Metadata repoMetadata = metadata.getMetadata();
|
||||
return retrieveAvailableVersionsFromMetadata( metadata.getMetadata() );
|
||||
}
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(
|
||||
Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
ArtifactRepository deploymentRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
|
||||
try
|
||||
{
|
||||
repositoryMetadataManager.resolveAlways( metadata, localRepository, deploymentRepository );
|
||||
}
|
||||
catch ( RepositoryMetadataResolutionException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
return retrieveAvailableVersionsFromMetadata( metadata.getMetadata() );
|
||||
}
|
||||
|
||||
private List<ArtifactVersion> retrieveAvailableVersionsFromMetadata( Metadata repoMetadata )
|
||||
{
|
||||
List<ArtifactVersion> versions;
|
||||
if ( ( repoMetadata != null ) && ( repoMetadata.getVersioning() != null ) )
|
||||
{
|
||||
List metadataVersions = repoMetadata.getVersioning().getVersions();
|
||||
versions = new ArrayList( metadataVersions.size() );
|
||||
for ( Iterator i = metadataVersions.iterator(); i.hasNext(); )
|
||||
List<String> metadataVersions = repoMetadata.getVersioning().getVersions();
|
||||
versions = new ArrayList<ArtifactVersion>( metadataVersions.size() );
|
||||
for ( String version : metadataVersions )
|
||||
{
|
||||
String version = (String) i.next();
|
||||
versions.add( new DefaultArtifactVersion( version ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
versions = Collections.EMPTY_LIST;
|
||||
versions = Collections.<ArtifactVersion> emptyList();
|
||||
}
|
||||
|
||||
return versions;
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
|||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.apache.maven.model.Dependency;
|
||||
|
@ -82,7 +83,7 @@ public class TestArtifactResolver
|
|||
}
|
||||
|
||||
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
|
||||
List remoteRepositories )
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
Model model = null;
|
||||
|
@ -141,8 +142,18 @@ public class TestArtifactResolver
|
|||
return new ResolutionGroup( artifact, artifacts, artifactRepositories );
|
||||
}
|
||||
|
||||
public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
|
||||
List remoteRepositories )
|
||||
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
|
||||
}
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(
|
||||
Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
ArtifactRepository remoteRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue