[MNG-1908] fix the performance problem with this particular fix

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@486484 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2006-12-13 04:13:15 +00:00
parent 5291a94c9d
commit d846d0d8aa
4 changed files with 53 additions and 7 deletions

View File

@ -272,13 +272,13 @@ public class DefaultWagonManager
// This one we will eat when looking through remote repositories
// because we want to cycle through them all before squawking.
getLogger().warn(
"Unable to get resource from repository " + repository.getId() + " (" + repository.getUrl() + ")" );
getLogger().warn( "Unable to get resource '" + artifact.getId() + "' from repository " +
repository.getId() + " (" + repository.getUrl() + ")" );
}
catch ( TransferFailedException e )
{
getLogger().warn(
"Unable to get resource from repository " + repository.getId() + " (" + repository.getUrl() + ")" );
getLogger().warn( "Unable to get resource '" + artifact.getId() + "' from repository " +
repository.getId() + " (" + repository.getUrl() + ")" );
}
}
@ -324,7 +324,7 @@ public class DefaultWagonManager
}
private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath,
TransferListener downloadMonitor, String checksumPolicy )
TransferListener downloadMonitor, String checksumPolicy )
throws TransferFailedException, ResourceDoesNotExistException
{
// TODO: better excetpions - transfer failed is not enough?
@ -398,7 +398,21 @@ public class DefaultWagonManager
// This should take care of creating destination directory now on
if ( destination.exists() )
{
downloaded = wagon.getIfNewer( remotePath, temp, destination.lastModified() );
try
{
downloaded = wagon.getIfNewer( remotePath, temp, destination.lastModified() );
if ( !downloaded )
{
// prevent additional checks of this artifact until it expires again
destination.setLastModified( System.currentTimeMillis() );
}
}
catch ( UnsupportedOperationException e )
{
// older wagons throw this. Just get() instead
wagon.get( remotePath, temp );
downloaded = true;
}
}
else
{

View File

@ -100,6 +100,7 @@ public class DefaultRepositoryMetadataManager
}
}
// TODO: should this be inside the above check?
// touch file so that this is not checked again until interval has passed
if ( file.exists() )
{

View File

@ -20,8 +20,13 @@ 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.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.repository.metadata.Snapshot;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.transform.ArtifactTransformationManager;
import org.apache.maven.wagon.ResourceDoesNotExistException;
@ -105,12 +110,36 @@ public class DefaultArtifactResolver
transformationManager.transformForResolve( artifact, remoteRepositories, localRepository );
boolean localCopy = false;
for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); )
{
ArtifactMetadata m = (ArtifactMetadata) i.next();
if ( m instanceof SnapshotArtifactRepositoryMetadata )
{
SnapshotArtifactRepositoryMetadata snapshotMetadata = (SnapshotArtifactRepositoryMetadata) m;
Metadata metadata = snapshotMetadata.getMetadata();
if ( metadata != null )
{
Versioning versioning = metadata.getVersioning();
if ( versioning != null )
{
Snapshot snapshot = versioning.getSnapshot();
if ( snapshot != null )
{
localCopy = snapshot.isLocalCopy();
}
}
}
}
}
File destination = artifact.getFile();
List repositories = remoteRepositories;
// TODO: would prefer the snapshot transformation took care of this. Maybe we need a "shouldresolve" flag.
if ( artifact.isSnapshot() && artifact.getBaseVersion().equals( artifact.getVersion() ) &&
destination.exists() )
destination.exists() && !localCopy )
{
Date comparisonDate = new Date( destination.lastModified() );

View File

@ -61,6 +61,8 @@ public abstract class AbstractVersionTransformation
repositoryMetadataManager.resolve( metadata, remoteRepositories, localRepository );
artifact.addMetadata( metadata );
Metadata repoMetadata = metadata.getMetadata();
String version = null;
if ( repoMetadata != null && repoMetadata.getVersioning() != null )