mirror of https://github.com/apache/maven.git
various straightening up
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@220244 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b82151f013
commit
eab42822ef
|
@ -26,7 +26,6 @@ import org.apache.maven.wagon.ResourceDoesNotExistException;
|
|||
import org.apache.maven.wagon.TransferFailedException;
|
||||
import org.apache.maven.wagon.UnsupportedProtocolException;
|
||||
import org.apache.maven.wagon.Wagon;
|
||||
import org.apache.maven.wagon.WagonException;
|
||||
import org.apache.maven.wagon.authentication.AuthenticationException;
|
||||
import org.apache.maven.wagon.authentication.AuthenticationInfo;
|
||||
import org.apache.maven.wagon.authorization.AuthorizationException;
|
||||
|
@ -113,7 +112,7 @@ public class DefaultWagonManager
|
|||
{
|
||||
String protocol = repository.getProtocol();
|
||||
|
||||
Wagon wagon = null;
|
||||
Wagon wagon;
|
||||
try
|
||||
{
|
||||
wagon = getWagon( protocol );
|
||||
|
@ -251,7 +250,8 @@ public class DefaultWagonManager
|
|||
getRemoteFile( remoteRepository, destination, remotePath, null );
|
||||
}
|
||||
|
||||
public void getRepositoryMetadata( RepositoryMetadata metadata, ArtifactRepository remoteRepository, File destination )
|
||||
public void getRepositoryMetadata( RepositoryMetadata metadata, ArtifactRepository remoteRepository,
|
||||
File destination )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
String remotePath = remoteRepository.formatAsFile( metadata.getRepositoryPath() );
|
||||
|
@ -315,7 +315,7 @@ public class DefaultWagonManager
|
|||
getAuthenticationInfo( repository.getId() ), getProxy( protocol ) );
|
||||
|
||||
boolean firstRun = true;
|
||||
boolean retry = false;
|
||||
boolean retry = true;
|
||||
|
||||
// this will run at most twice. The first time, the firstRun flag is turned off, and if the retry flag
|
||||
// is set on the first run, it will be turned off and not re-set on the second try. This is because the
|
||||
|
@ -339,61 +339,52 @@ public class DefaultWagonManager
|
|||
{
|
||||
verifyChecksum( sha1ChecksumObserver, temp, remotePath, ".sha1", wagon );
|
||||
}
|
||||
catch ( WagonException sha1TryException )
|
||||
catch ( ChecksumFailedException e )
|
||||
{
|
||||
// if we catch a ChecksumFailedException, it means the transfer/read succeeded, but the checksum
|
||||
// doesn't match. This could be a problem with the server (ibiblio HTTP-200 error page), so we'll
|
||||
// try this up to two times. On the second try, we'll handle it as a bona-fide error, based on the
|
||||
// repository's checksum checking policy.
|
||||
if ( sha1TryException instanceof ChecksumFailedException )
|
||||
{
|
||||
// if this is the second try, handle the problem...otherwise, let it try again.
|
||||
if ( firstRun )
|
||||
{
|
||||
retry = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handleChecksumFailure( repository, sha1TryException.getMessage(),
|
||||
sha1TryException.getCause() );
|
||||
handleChecksumFailure( repository, e.getMessage(), e.getCause() );
|
||||
}
|
||||
}
|
||||
catch ( ResourceDoesNotExistException sha1TryException )
|
||||
{
|
||||
getLogger().debug( "SHA1 not found, trying MD5", sha1TryException );
|
||||
|
||||
// if this IS NOT a ChecksumFailedException, it was a problem with transfer/read of the checksum
|
||||
// file...we'll try again with the MD5 checksum.
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
verifyChecksum( md5ChecksumObserver, temp, remotePath, ".md5", wagon );
|
||||
}
|
||||
catch ( WagonException md5TryException )
|
||||
catch ( ChecksumFailedException e )
|
||||
{
|
||||
// if we also fail to verify based on the MD5 checksum, and the checksum transfer/read
|
||||
// succeeded, then we need to determine whether to retry or handle it as a failure.
|
||||
if ( md5TryException instanceof ChecksumFailedException )
|
||||
{
|
||||
// only retry once.
|
||||
if ( firstRun )
|
||||
{
|
||||
retry = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handleChecksumFailure( repository, md5TryException.getMessage(),
|
||||
md5TryException.getCause() );
|
||||
handleChecksumFailure( repository, e.getMessage(), e.getCause() );
|
||||
}
|
||||
}
|
||||
// otherwise, this was a failed transfer, and we don't want to retry.
|
||||
else
|
||||
catch ( ResourceDoesNotExistException md5TryException )
|
||||
{
|
||||
// this was a failed transfer, and we don't want to retry.
|
||||
handleChecksumFailure( repository, "Error retrieving checksum file for " + remotePath,
|
||||
md5TryException );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
// reinstate the download monitor...
|
||||
if ( downloadMonitor != null )
|
||||
{
|
||||
|
@ -404,7 +395,6 @@ public class DefaultWagonManager
|
|||
firstRun = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( ConnectionException e )
|
||||
{
|
||||
throw new TransferFailedException( "Connection failed: ", e );
|
||||
|
@ -465,7 +455,7 @@ public class DefaultWagonManager
|
|||
|
||||
private void verifyChecksum( ChecksumObserver checksumObserver, File destination, String remotePath,
|
||||
String checksumFileExtension, Wagon wagon )
|
||||
throws WagonException
|
||||
throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -478,12 +468,8 @@ public class DefaultWagonManager
|
|||
String expectedChecksum = FileUtils.fileRead( checksumFile );
|
||||
if ( !expectedChecksum.equals( actualChecksum ) )
|
||||
{
|
||||
// getLogger().warn(
|
||||
// "*** CHECKSUM MISMATCH - currently disabled fail due to bad repository checksums ***" );
|
||||
|
||||
throw new ChecksumFailedException(
|
||||
"Checksum failed on download: local = '" + actualChecksum + "'; remote = '" + expectedChecksum +
|
||||
"'" );
|
||||
throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum +
|
||||
"'; remote = '" + expectedChecksum + "'" );
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.artifact.manager;
|
|||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
import org.apache.maven.wagon.TransferFailedException;
|
||||
|
@ -46,23 +45,22 @@ public interface WagonManager
|
|||
void getArtifact( Artifact artifact, List remoteRepositories, File destination )
|
||||
throws TransferFailedException, ResourceDoesNotExistException;
|
||||
|
||||
public void getArtifact( Artifact artifact, ArtifactRepository repository, File destination )
|
||||
void getArtifact( Artifact artifact, ArtifactRepository repository, File destination )
|
||||
throws TransferFailedException, ResourceDoesNotExistException;
|
||||
|
||||
void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository )
|
||||
throws TransferFailedException;
|
||||
|
||||
public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository )
|
||||
void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository )
|
||||
throws TransferFailedException;
|
||||
|
||||
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination )
|
||||
void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination )
|
||||
throws TransferFailedException, ResourceDoesNotExistException;
|
||||
|
||||
public void putRepositoryMetadata( File source, RepositoryMetadata metadata, ArtifactRepository repository )
|
||||
void putRepositoryMetadata( File source, RepositoryMetadata metadata, ArtifactRepository repository )
|
||||
throws TransferFailedException;
|
||||
|
||||
public void getRepositoryMetadata( RepositoryMetadata metadata, ArtifactRepository remoteRepository,
|
||||
File destination )
|
||||
void getRepositoryMetadata( RepositoryMetadata metadata, ArtifactRepository remoteRepository, File destination )
|
||||
throws TransferFailedException, ResourceDoesNotExistException;
|
||||
|
||||
void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts );
|
||||
|
|
|
@ -60,11 +60,8 @@ public class DefaultArtifactResolver
|
|||
public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
if ( artifact == null )
|
||||
if ( artifact != null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Check for the existence of the artifact in the specified local
|
||||
// ArtifactRepository. If it is present then simply return as the
|
||||
|
@ -125,6 +122,7 @@ public class DefaultArtifactResolver
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
|
|
Loading…
Reference in New Issue