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;
|
||||
|
@ -100,10 +99,10 @@ public class DefaultWagonManager
|
|||
}
|
||||
|
||||
public void putRepositoryMetadata( File source, RepositoryMetadata metadata, ArtifactRepository repository )
|
||||
throws TransferFailedException
|
||||
throws TransferFailedException
|
||||
{
|
||||
getLogger().info( "Uploading " + metadata );
|
||||
|
||||
|
||||
putRemoteFile( repository, source, repository.formatAsFile( metadata.getRepositoryPath() ), null );
|
||||
}
|
||||
|
||||
|
@ -113,7 +112,7 @@ public class DefaultWagonManager
|
|||
{
|
||||
String protocol = repository.getProtocol();
|
||||
|
||||
Wagon wagon = null;
|
||||
Wagon wagon;
|
||||
try
|
||||
{
|
||||
wagon = getWagon( protocol );
|
||||
|
@ -251,13 +250,14 @@ public class DefaultWagonManager
|
|||
getRemoteFile( remoteRepository, destination, remotePath, null );
|
||||
}
|
||||
|
||||
public void getRepositoryMetadata( RepositoryMetadata metadata, ArtifactRepository remoteRepository, File destination )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
public void getRepositoryMetadata( RepositoryMetadata metadata, ArtifactRepository remoteRepository,
|
||||
File destination )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
String remotePath = remoteRepository.formatAsFile( metadata.getRepositoryPath() );
|
||||
|
||||
|
||||
getLogger().info( "Retrieving " + metadata );
|
||||
|
||||
|
||||
getRemoteFile( remoteRepository, destination, remotePath, null );
|
||||
}
|
||||
|
||||
|
@ -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,70 +339,60 @@ 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 ( firstRun )
|
||||
{
|
||||
// if this is the second try, handle the problem...otherwise, let it try again.
|
||||
retry = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
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.
|
||||
try
|
||||
{
|
||||
verifyChecksum( md5ChecksumObserver, temp, remotePath, ".md5", wagon );
|
||||
}
|
||||
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 ( firstRun )
|
||||
{
|
||||
retry = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handleChecksumFailure( repository, sha1TryException.getMessage(),
|
||||
sha1TryException.getCause() );
|
||||
handleChecksumFailure( repository, e.getMessage(), e.getCause() );
|
||||
}
|
||||
}
|
||||
// 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
|
||||
catch ( ResourceDoesNotExistException md5TryException )
|
||||
{
|
||||
try
|
||||
{
|
||||
verifyChecksum( md5ChecksumObserver, temp, remotePath, ".md5", wagon );
|
||||
}
|
||||
catch ( WagonException md5TryException )
|
||||
{
|
||||
// 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() );
|
||||
}
|
||||
}
|
||||
// otherwise, this was a failed transfer, and we don't want to retry.
|
||||
else
|
||||
{
|
||||
handleChecksumFailure( repository, "Error retrieving checksum file for " + remotePath,
|
||||
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 )
|
||||
{
|
||||
wagon.addTransferListener( downloadMonitor );
|
||||
}
|
||||
|
||||
// unset the firstRun flag, so we don't get caught in an infinite loop...
|
||||
firstRun = false;
|
||||
// reinstate the download monitor...
|
||||
if ( downloadMonitor != null )
|
||||
{
|
||||
wagon.addTransferListener( downloadMonitor );
|
||||
}
|
||||
|
||||
// unset the firstRun flag, so we don't get caught in an infinite loop...
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
catch ( ConnectionException 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,29 +45,28 @@ 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 );
|
||||
|
||||
void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey,
|
||||
String passphrase );
|
||||
String passphrase );
|
||||
|
||||
void addMirror( String id, String mirrorOf, String url );
|
||||
|
||||
|
|
|
@ -60,68 +60,66 @@ 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
|
||||
// request for resolution has been satisfied.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Check for the existence of the artifact in the specified local
|
||||
// ArtifactRepository. If it is present then simply return as the
|
||||
// request for resolution has been satisfied.
|
||||
// ----------------------------------------------------------------------
|
||||
String localPath = localRepository.pathOf( artifact );
|
||||
|
||||
String localPath = localRepository.pathOf( artifact );
|
||||
artifact.setFile( new File( localRepository.getBasedir(), localPath ) );
|
||||
|
||||
artifact.setFile( new File( localRepository.getBasedir(), localPath ) );
|
||||
|
||||
// TODO: better to have a transform manager, or reuse the handler manager again so we don't have these requirements duplicated all over?
|
||||
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
|
||||
{
|
||||
ArtifactTransformation transform = (ArtifactTransformation) i.next();
|
||||
try
|
||||
// TODO: better to have a transform manager, or reuse the handler manager again so we don't have these requirements duplicated all over?
|
||||
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
|
||||
{
|
||||
transform.transformForResolve( artifact, remoteRepositories, localRepository );
|
||||
}
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
|
||||
}
|
||||
}
|
||||
|
||||
File destination = artifact.getFile();
|
||||
if ( !destination.exists() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( artifact.getRepository() != null )
|
||||
ArtifactTransformation transform = (ArtifactTransformation) i.next();
|
||||
try
|
||||
{
|
||||
// the transformations discovered the artifact - so use it exclusively
|
||||
wagonManager.getArtifact( artifact, artifact.getRepository(), destination );
|
||||
transform.transformForResolve( artifact, remoteRepositories, localRepository );
|
||||
}
|
||||
else
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
wagonManager.getArtifact( artifact, remoteRepositories, destination );
|
||||
}
|
||||
|
||||
// must be after the artifact is downloaded
|
||||
for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); )
|
||||
{
|
||||
ArtifactMetadata metadata = (ArtifactMetadata) i.next();
|
||||
metadata.storeInLocalRepository( localRepository );
|
||||
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
|
||||
}
|
||||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
|
||||
File destination = artifact.getFile();
|
||||
if ( !destination.exists() )
|
||||
{
|
||||
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
|
||||
}
|
||||
catch ( TransferFailedException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
|
||||
}
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
|
||||
try
|
||||
{
|
||||
if ( artifact.getRepository() != null )
|
||||
{
|
||||
// the transformations discovered the artifact - so use it exclusively
|
||||
wagonManager.getArtifact( artifact, artifact.getRepository(), destination );
|
||||
}
|
||||
else
|
||||
{
|
||||
wagonManager.getArtifact( artifact, remoteRepositories, destination );
|
||||
}
|
||||
|
||||
// must be after the artifact is downloaded
|
||||
for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); )
|
||||
{
|
||||
ArtifactMetadata metadata = (ArtifactMetadata) i.next();
|
||||
metadata.storeInLocalRepository( localRepository );
|
||||
}
|
||||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
|
||||
}
|
||||
catch ( TransferFailedException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
|
||||
}
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue