PR: MNG-122

use real exceptions for repository metadata

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@320683 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-13 08:04:27 +00:00
parent 1957f5118d
commit 04e02209b1
23 changed files with 399 additions and 115 deletions

View File

@ -19,8 +19,8 @@ package org.apache.maven.artifact.deployer;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataDeploymentException;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.artifact.transform.ArtifactTransformationManager;
import org.apache.maven.wagon.TransferFailedException;
@ -88,15 +88,15 @@ public class DefaultArtifactDeployer
}
catch ( TransferFailedException e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
}
catch ( ArtifactMetadataRetrievalException e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
throw new ArtifactDeploymentException( "Error deploying artifact: " + e.getMessage(), e );
}
catch ( IOException e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
throw new ArtifactDeploymentException( "Error deploying artifact: " + e.getMessage(), e );
}
catch ( RepositoryMetadataDeploymentException e )
{
throw new ArtifactDeploymentException( "Error installing artifact's metadata: " + e.getMessage(), e );
}
}
}

View File

@ -18,8 +18,8 @@ package org.apache.maven.artifact.installer;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataInstallationException;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.artifact.transform.ArtifactTransformationManager;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@ -81,11 +81,11 @@ public class DefaultArtifactInstaller
}
catch ( IOException e )
{
throw new ArtifactInstallationException( "Error installing artifact: ", e );
throw new ArtifactInstallationException( "Error installing artifact: " + e.getMessage(), e );
}
catch ( ArtifactMetadataRetrievalException e )
catch ( RepositoryMetadataInstallationException e )
{
throw new ArtifactInstallationException( "Error installing artifact: ", e );
throw new ArtifactInstallationException( "Error installing artifact's metadata: " + e.getMessage(), e );
}
}
}

View File

@ -18,7 +18,6 @@ package org.apache.maven.artifact.repository.metadata;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
@ -59,7 +58,7 @@ public abstract class AbstractRepositoryMetadata
}
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataStoreException
{
try
{
@ -67,11 +66,11 @@ public abstract class AbstractRepositoryMetadata
}
catch ( IOException e )
{
throw new ArtifactMetadataRetrievalException( "Error updating group repository metadata", e );
throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e );
}
catch ( XmlPullParserException e )
{
throw new ArtifactMetadataRetrievalException( "Error updating group repository metadata", e );
throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e );
}
}

View File

@ -18,7 +18,6 @@ package org.apache.maven.artifact.repository.metadata;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
@ -54,7 +53,7 @@ public class DefaultRepositoryMetadataManager
private Set cachedMetadata = new HashSet();
public void resolve( RepositoryMetadata metadata, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataResolutionException
{
boolean alreadyResolved = alreadyResolved( metadata );
if ( !alreadyResolved )
@ -63,8 +62,8 @@ public class DefaultRepositoryMetadataManager
{
ArtifactRepository repository = (ArtifactRepository) i.next();
ArtifactRepositoryPolicy policy = metadata.isSnapshot() ? repository.getSnapshots()
: repository.getReleases();
ArtifactRepositoryPolicy policy =
metadata.isSnapshot() ? repository.getSnapshots() : repository.getReleases();
if ( !policy.isEnabled() )
{
@ -96,12 +95,41 @@ public class DefaultRepositoryMetadataManager
else
{
// this ensures that files are not continuously checked when they don't exist remotely
metadata.storeInLocalRepository( localRepository, repository );
try
{
metadata.storeInLocalRepository( localRepository, repository );
}
catch ( RepositoryMetadataStoreException e )
{
throw new RepositoryMetadataResolutionException(
"Unable to store local copy of metadata: " + e.getMessage(), e );
}
}
}
}
cachedMetadata.add( metadata.getKey() );
}
try
{
mergeMetadata( metadata, remoteRepositories, localRepository );
}
catch ( RepositoryMetadataStoreException e )
{
throw new RepositoryMetadataResolutionException(
"Unable to store local copy of metadata: " + e.getMessage(), e );
}
catch ( RepositoryMetadataReadException e )
{
throw new RepositoryMetadataResolutionException( "Unable to read local copy of metadata: " + e.getMessage(),
e );
}
}
private void mergeMetadata( RepositoryMetadata metadata, List remoteRepositories,
ArtifactRepository localRepository )
throws RepositoryMetadataStoreException, RepositoryMetadataReadException
{
// TODO: currently this is first wins, but really we should take the latest by comparing either the
// snapshot timestamp, or some other timestamp later encoded into the metadata.
// TODO: this needs to be repeated here so the merging doesn't interfere with the written metadata
@ -113,8 +141,8 @@ public class DefaultRepositoryMetadataManager
{
ArtifactRepository repository = (ArtifactRepository) i.next();
ArtifactRepositoryPolicy policy = metadata.isSnapshot() ? repository.getSnapshots()
: repository.getReleases();
ArtifactRepositoryPolicy policy =
metadata.isSnapshot() ? repository.getSnapshots() : repository.getReleases();
if ( policy.isEnabled() && !repository.isBlacklisted() )
{
@ -131,6 +159,13 @@ public class DefaultRepositoryMetadataManager
selected = localRepository;
}
updateSnapshotMetadata( metadata, previousMetadata, selected, localRepository );
}
private void updateSnapshotMetadata( RepositoryMetadata metadata, Map previousMetadata, ArtifactRepository selected,
ArtifactRepository localRepository )
throws RepositoryMetadataStoreException
{
// TODO: this could be a lot nicer... should really be in the snapshot transformation?
if ( metadata.isSnapshot() )
{
@ -177,7 +212,7 @@ public class DefaultRepositoryMetadataManager
private boolean loadMetadata( RepositoryMetadata repoMetadata, ArtifactRepository remoteRepository,
ArtifactRepository localRepository, Map previousMetadata )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataReadException
{
boolean setRepository = false;
@ -210,7 +245,7 @@ public class DefaultRepositoryMetadataManager
* @todo share with DefaultPluginMappingManager.
*/
protected static Metadata readMetadata( File mappingFile )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataReadException
{
Metadata result;
@ -225,15 +260,17 @@ public class DefaultRepositoryMetadataManager
}
catch ( FileNotFoundException e )
{
throw new ArtifactMetadataRetrievalException( "Cannot read version information from: " + mappingFile, e );
throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "'", e );
}
catch ( IOException e )
{
throw new ArtifactMetadataRetrievalException( "Cannot read version information from: " + mappingFile, e );
throw new RepositoryMetadataReadException(
"Cannot read metadata from '" + mappingFile + "': " + e.getMessage(), e );
}
catch ( XmlPullParserException e )
{
throw new ArtifactMetadataRetrievalException( "Cannot parse version information from: " + mappingFile, e );
throw new RepositoryMetadataReadException(
"Cannot read metadata from '" + mappingFile + "': " + e.getMessage(), e );
}
finally
{
@ -244,12 +281,12 @@ public class DefaultRepositoryMetadataManager
public void resolveAlways( RepositoryMetadata metadata, ArtifactRepository localRepository,
ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataResolutionException
{
if ( !wagonManager.isOnline() )
{
// metadata is required for deployment, can't be offline
throw new ArtifactMetadataRetrievalException(
throw new RepositoryMetadataResolutionException(
"System is offline. Cannot resolve required metadata:\n" + metadata.extendedToString() );
}
@ -258,16 +295,23 @@ public class DefaultRepositoryMetadataManager
resolveAlways( metadata, remoteRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, false );
if ( file.exists() )
try
{
Metadata prevMetadata = readMetadata( file );
metadata.setMetadata( prevMetadata );
if ( file.exists() )
{
Metadata prevMetadata = readMetadata( file );
metadata.setMetadata( prevMetadata );
}
}
catch ( RepositoryMetadataReadException e )
{
throw new RepositoryMetadataResolutionException( e.getMessage(), e );
}
}
private void resolveAlways( ArtifactMetadata metadata, ArtifactRepository repository, File file,
String checksumPolicy, boolean allowBlacklisting )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataResolutionException
{
if ( !wagonManager.isOnline() )
{
@ -280,7 +324,7 @@ public class DefaultRepositoryMetadataManager
else
{
// metadata is required for deployment, can't be offline
throw new ArtifactMetadataRetrievalException(
throw new RepositoryMetadataResolutionException(
"System is offline. Cannot resolve required metadata:\n" + metadata.extendedToString() );
}
}
@ -316,12 +360,12 @@ public class DefaultRepositoryMetadataManager
public void deploy( ArtifactMetadata metadata, ArtifactRepository localRepository,
ArtifactRepository deploymentRepository )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataDeploymentException
{
if ( !wagonManager.isOnline() )
{
// deployment shouldn't silently fail when offline
throw new ArtifactMetadataRetrievalException(
throw new RepositoryMetadataDeploymentException(
"System is offline. Cannot deploy metadata:\n" + metadata.extendedToString() );
}
@ -330,9 +374,24 @@ public class DefaultRepositoryMetadataManager
File file = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) );
resolveAlways( metadata, deploymentRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, false );
try
{
resolveAlways( metadata, deploymentRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, false );
}
catch ( RepositoryMetadataResolutionException e )
{
throw new RepositoryMetadataDeploymentException(
"Unable to get previous metadata to update: " + e.getMessage(), e );
}
metadata.storeInLocalRepository( localRepository, deploymentRepository );
try
{
metadata.storeInLocalRepository( localRepository, deploymentRepository );
}
catch ( RepositoryMetadataStoreException e )
{
throw new RepositoryMetadataDeploymentException( "Error installing metadata: " + e.getMessage(), e );
}
try
{
@ -340,14 +399,20 @@ public class DefaultRepositoryMetadataManager
}
catch ( TransferFailedException e )
{
// TODO: wrong exception
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
throw new RepositoryMetadataDeploymentException( "Error while deploying metadata: " + e.getMessage(), e );
}
}
public void install( ArtifactMetadata metadata, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataInstallationException
{
metadata.storeInLocalRepository( localRepository, localRepository );
try
{
metadata.storeInLocalRepository( localRepository, localRepository );
}
catch ( RepositoryMetadataStoreException e )
{
throw new RepositoryMetadataInstallationException( "Error installing metadata: " + e.getMessage(), e );
}
}
}

View File

@ -17,7 +17,6 @@ package org.apache.maven.artifact.repository.metadata;
*/
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.List;
@ -25,11 +24,11 @@ import java.util.List;
public interface RepositoryMetadataManager
{
void resolve( RepositoryMetadata repositoryMetadata, List repositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException;
throws RepositoryMetadataResolutionException;
void resolveAlways( RepositoryMetadata metadata, ArtifactRepository localRepository,
ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException;
throws RepositoryMetadataResolutionException;
/**
* Deploy metadata to the remote repository.
@ -40,7 +39,7 @@ public interface RepositoryMetadataManager
*/
void deploy( ArtifactMetadata metadata, ArtifactRepository localRepository,
ArtifactRepository deploymentRepository )
throws ArtifactMetadataRetrievalException;
throws RepositoryMetadataDeploymentException;
/**
* Install the metadata in the local repository.
@ -49,5 +48,5 @@ public interface RepositoryMetadataManager
* @param localRepository the local repository
*/
void install( ArtifactMetadata metadata, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException;
throws RepositoryMetadataInstallationException;
}

View File

@ -19,7 +19,6 @@ package org.apache.maven.artifact.resolver;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
@ -102,14 +101,7 @@ public class DefaultArtifactResolver
artifact.setFile( new File( localRepository.getBasedir(), localPath ) );
try
{
transformationManager.transformForResolve( artifact, remoteRepositories, localRepository );
}
catch ( ArtifactMetadataRetrievalException e )
{
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
}
transformationManager.transformForResolve( artifact, remoteRepositories, localRepository );
File destination = artifact.getFile();
boolean resolved = false;

View File

@ -18,12 +18,12 @@ package org.apache.maven.artifact.transform;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@ -46,7 +46,7 @@ public abstract class AbstractVersionTransformation
protected WagonManager wagonManager;
protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataResolutionException
{
RepositoryMetadata metadata;
// Don't use snapshot metadata for LATEST (which isSnapshot returns true for)

View File

@ -17,8 +17,10 @@ package org.apache.maven.artifact.transform;
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
import org.apache.maven.artifact.installer.ArtifactInstallationException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import java.util.Iterator;
import java.util.List;
@ -29,7 +31,7 @@ public class DefaultArtifactTransformationManager
private List artifactTransformations;
public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
throws ArtifactResolutionException
{
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
{
@ -39,7 +41,7 @@ public class DefaultArtifactTransformationManager
}
public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
throws ArtifactInstallationException
{
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
{
@ -50,7 +52,7 @@ public class DefaultArtifactTransformationManager
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
throws ArtifactDeploymentException
{
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
{

View File

@ -17,9 +17,10 @@ package org.apache.maven.artifact.transform;
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import java.util.List;
@ -27,31 +28,35 @@ public class LatestArtifactTransformation
extends AbstractVersionTransformation
{
public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
throws ArtifactResolutionException
{
if ( Artifact.LATEST_VERSION.equals( artifact.getVersion() ) )
{
String version = resolveVersion( artifact, localRepository, remoteRepositories );
if ( Artifact.LATEST_VERSION.equals( version ) )
try
{
throw new ArtifactMetadataRetrievalException(
"Unable to determine the latest version for artifact " + artifact );
}
String version = resolveVersion( artifact, localRepository, remoteRepositories );
if ( Artifact.LATEST_VERSION.equals( version ) )
{
throw new ArtifactResolutionException( "Unable to determine the latest version", artifact );
}
artifact.setBaseVersion( version );
artifact.updateVersion( version, localRepository );
artifact.setBaseVersion( version );
artifact.updateVersion( version, localRepository );
}
catch ( RepositoryMetadataResolutionException e )
{
throw new ArtifactResolutionException( e.getMessage(), artifact, e );
}
}
}
public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{
// metadata is added via addPluginArtifactMetadata
}
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{
// metadata is added via addPluginArtifactMetadata
}

View File

@ -18,10 +18,11 @@ package org.apache.maven.artifact.transform;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import java.util.List;
@ -35,25 +36,30 @@ public class ReleaseArtifactTransformation
extends AbstractVersionTransformation
{
public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
throws ArtifactResolutionException
{
if ( Artifact.RELEASE_VERSION.equals( artifact.getVersion() ) )
{
String version = resolveVersion( artifact, localRepository, remoteRepositories );
if ( Artifact.RELEASE_VERSION.equals( version ) )
try
{
throw new ArtifactMetadataRetrievalException(
"Unable to determine the release version for artifact " + artifact );
}
String version = resolveVersion( artifact, localRepository, remoteRepositories );
artifact.setBaseVersion( version );
artifact.updateVersion( version, localRepository );
if ( Artifact.RELEASE_VERSION.equals( version ) )
{
throw new ArtifactResolutionException( "Unable to determine the release version", artifact );
}
artifact.setBaseVersion( version );
artifact.updateVersion( version, localRepository );
}
catch ( RepositoryMetadataResolutionException e )
{
throw new ArtifactResolutionException( e.getMessage(), artifact, e );
}
}
}
public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{
ArtifactMetadata metadata = createMetadata( artifact );
@ -62,7 +68,6 @@ public class ReleaseArtifactTransformation
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{
ArtifactMetadata metadata = createMetadata( artifact );

View File

@ -17,13 +17,15 @@ package org.apache.maven.artifact.transform;
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
import org.apache.maven.artifact.repository.metadata.Snapshot;
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.codehaus.plexus.util.StringUtils;
import java.text.DateFormat;
@ -48,18 +50,24 @@ public class SnapshotTransformation
private static final String UTC_TIMESTAMP_PATTERN = "yyyyMMdd.HHmmss";
public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
throws ArtifactResolutionException
{
// Only select snapshots that are unresolved (eg 1.0-SNAPSHOT, not 1.0-20050607.123456)
if ( artifact.isSnapshot() && artifact.getBaseVersion().equals( artifact.getVersion() ) )
{
String version = resolveVersion( artifact, localRepository, remoteRepositories );
artifact.updateVersion( version, localRepository );
try
{
String version = resolveVersion( artifact, localRepository, remoteRepositories );
artifact.updateVersion( version, localRepository );
}
catch ( RepositoryMetadataResolutionException e )
{
throw new ArtifactResolutionException( e.getMessage(), artifact, e );
}
}
}
public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{
if ( artifact.isSnapshot() )
{
@ -73,7 +81,7 @@ public class SnapshotTransformation
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
throws ArtifactDeploymentException
{
if ( artifact.isSnapshot() )
{
@ -84,9 +92,17 @@ public class SnapshotTransformation
}
// we update the build number anyway so that it doesn't get lost. It requires the timestamp to take effect
int buildNumber = resolveLatestSnapshotBuildNumber( artifact, localRepository, remoteRepository );
try
{
int buildNumber = resolveLatestSnapshotBuildNumber( artifact, localRepository, remoteRepository );
snapshot.setBuildNumber( buildNumber + 1 );
snapshot.setBuildNumber( buildNumber + 1 );
}
catch ( RepositoryMetadataResolutionException e )
{
throw new ArtifactDeploymentException( "Error retrieving previous build number for artifact '" +
artifact.getDependencyConflictId() + "': " + e.getMessage(), e );
}
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );
@ -127,14 +143,14 @@ public class SnapshotTransformation
private int resolveLatestSnapshotBuildNumber( Artifact artifact, ArtifactRepository localRepository,
ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataResolutionException
{
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact );
if ( !wagonManager.isOnline() )
{
// build number is a required feature for metadata consistency
throw new ArtifactMetadataRetrievalException(
throw new RepositoryMetadataResolutionException(
"System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" );
}

View File

@ -17,6 +17,7 @@ package org.apache.maven.artifact.metadata;
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException;
/**
* Contains metadata about an artifact, and methods to retrieve/store it from an artifact repository.
@ -77,7 +78,7 @@ public interface ArtifactMetadata
* @todo this should only be needed on the repository metadata
*/
void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException;
throws RepositoryMetadataStoreException;
String extendedToString();
}

View File

@ -0,0 +1,37 @@
package org.apache.maven.artifact.repository.metadata;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Error while deploying repository metadata.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class RepositoryMetadataDeploymentException
extends Throwable
{
public RepositoryMetadataDeploymentException( String message )
{
super( message );
}
public RepositoryMetadataDeploymentException( String message, Exception e )
{
super( message, e );
}
}

View File

@ -0,0 +1,37 @@
package org.apache.maven.artifact.repository.metadata;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Error while installing repository metadata.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class RepositoryMetadataInstallationException
extends Throwable
{
public RepositoryMetadataInstallationException( String message )
{
super( message );
}
public RepositoryMetadataInstallationException( String message, Exception e )
{
super( message, e );
}
}

View File

@ -0,0 +1,35 @@
package org.apache.maven.artifact.repository.metadata;/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Problem storing the repository metadata in the local repository.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class RepositoryMetadataReadException
extends Exception
{
public RepositoryMetadataReadException( String message )
{
super( message );
}
public RepositoryMetadataReadException( String message, Exception e )
{
super( message, e );
}
}

View File

@ -0,0 +1,37 @@
package org.apache.maven.artifact.repository.metadata;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Error while retrieving repository metadata from the repository.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class RepositoryMetadataResolutionException
extends Exception
{
public RepositoryMetadataResolutionException( String message )
{
super( message );
}
public RepositoryMetadataResolutionException( String message, Exception e )
{
super( message, e );
}
}

View File

@ -0,0 +1,37 @@
package org.apache.maven.artifact.repository.metadata;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Problem storing the repository metadata in the local repository.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class RepositoryMetadataStoreException
extends Exception
{
public RepositoryMetadataStoreException( String message )
{
super( message );
}
public RepositoryMetadataStoreException( String message, Exception e )
{
super( message, e );
}
}

View File

@ -44,11 +44,16 @@ public class ArtifactResolutionException
super( message, artifact );
}
protected ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories )
public ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories )
{
super( message, artifact, remoteRepositories );
}
public ArtifactResolutionException( String message, Artifact artifact, Throwable t )
{
super( message, artifact, null, t );
}
protected ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories, Throwable t )
{
super( message, artifact, remoteRepositories, t );

View File

@ -17,8 +17,10 @@ package org.apache.maven.artifact.transform;
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
import org.apache.maven.artifact.installer.ArtifactInstallationException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import java.util.List;
@ -40,7 +42,7 @@ public interface ArtifactTransformation
* @param localRepository the local repository
*/
void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException;
throws ArtifactResolutionException;
/**
* Take in a artifact and return the transformed artifact for locating in the local repository. If no
@ -50,7 +52,7 @@ public interface ArtifactTransformation
* @param localRepository the local repository it will be stored in
*/
void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException;
throws ArtifactInstallationException;
/**
* Take in a artifact and return the transformed artifact for distributing toa remote repository. If no
@ -62,6 +64,6 @@ public interface ArtifactTransformation
*/
void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException;
throws ArtifactDeploymentException;
}

View File

@ -17,8 +17,10 @@ package org.apache.maven.artifact.transform;
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
import org.apache.maven.artifact.installer.ArtifactInstallationException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import java.util.List;
@ -38,7 +40,7 @@ public interface ArtifactTransformationManager
* @param localRepository the local repository
*/
void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException;
throws ArtifactResolutionException;
/**
* Take in a artifact and return the transformed artifact for locating in the local repository. If no
@ -48,7 +50,7 @@ public interface ArtifactTransformationManager
* @param localRepository the local repository it will be stored in
*/
void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException;
throws ArtifactInstallationException;
/**
* Take in a artifact and return the transformed artifact for distributing toa remote repository. If no
@ -60,6 +62,6 @@ public interface ArtifactTransformationManager
*/
void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException;
throws ArtifactDeploymentException;
}

View File

@ -16,13 +16,13 @@ package org.apache.maven.plugin;
* limitations under the License.
*/
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.Plugin;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.util.ArrayList;
@ -81,7 +81,7 @@ public class DefaultPluginMappingManager
{
loadPluginMappings( groupId, pluginRepositories, localRepository );
}
catch ( ArtifactMetadataRetrievalException e )
catch ( RepositoryMetadataResolutionException e )
{
getLogger().warn( "Cannot resolve plugin-mapping metadata for groupId: " + groupId + " - IGNORING." );
@ -91,7 +91,7 @@ public class DefaultPluginMappingManager
}
private void loadPluginMappings( String groupId, List pluginRepositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataResolutionException
{
RepositoryMetadata metadata = new GroupRepositoryMetadata( groupId );

View File

@ -26,6 +26,7 @@ import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
@ -343,7 +344,14 @@ public class MavenMetadataSource
throws ArtifactMetadataRetrievalException
{
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
repositoryMetadataManager.resolve( metadata, remoteRepositories, localRepository );
try
{
repositoryMetadataManager.resolve( metadata, remoteRepositories, localRepository );
}
catch ( RepositoryMetadataResolutionException e )
{
throw new ArtifactMetadataRetrievalException( e.getMessage(), e );
}
List versions;
Metadata repoMetadata = metadata.getMetadata();

View File

@ -20,8 +20,8 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactStatus;
import org.apache.maven.artifact.metadata.AbstractArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
@ -73,7 +73,7 @@ public class ProjectArtifactMetadata
}
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException
throws RepositoryMetadataStoreException
{
File destination = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) );
@ -104,15 +104,15 @@ public class ProjectArtifactMetadata
}
catch ( FileNotFoundException e )
{
throw new ArtifactMetadataRetrievalException( "Error rewriting POM", e );
throw new RepositoryMetadataStoreException( "Error rewriting POM", e );
}
catch ( IOException e )
{
throw new ArtifactMetadataRetrievalException( "Error rewriting POM", e );
throw new RepositoryMetadataStoreException( "Error rewriting POM", e );
}
catch ( XmlPullParserException e )
{
throw new ArtifactMetadataRetrievalException( "Error rewriting POM", e );
throw new RepositoryMetadataStoreException( "Error rewriting POM", e );
}
finally
{