improve reporting

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163710 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-03-30 01:17:34 +00:00
parent c8e40de1e4
commit b03435f9e1
2 changed files with 29 additions and 14 deletions

View File

@ -211,7 +211,7 @@ public class DefaultWagonManager
throw new TransferFailedException( "Failed to determine path for artifact", e ); throw new TransferFailedException( "Failed to determine path for artifact", e );
} }
getRemoteFile( repository, destination, remotePath ); getRemoteFile( repository, destination, remotePath, downloadMonitor );
} }
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination ) public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination )
@ -228,10 +228,12 @@ public class DefaultWagonManager
throw new TransferFailedException( "Failed to determine path for artifact", e ); throw new TransferFailedException( "Failed to determine path for artifact", e );
} }
getRemoteFile( remoteRepository, destination, remotePath ); // TODO: maybe some other listener that still notifies when metadata is being retrieved?
getRemoteFile( remoteRepository, destination, remotePath, null );
} }
private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath ) private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath,
TransferListener downloadMonitor )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
Wagon wagon; Wagon wagon;
@ -255,7 +257,6 @@ public class DefaultWagonManager
//wagon.addTransferListener( md5SumObserver ); //wagon.addTransferListener( md5SumObserver );
// TODO: probably don't want this on metadata...
if ( downloadMonitor != null ) if ( downloadMonitor != null )
{ {
wagon.addTransferListener( downloadMonitor ); wagon.addTransferListener( downloadMonitor );

View File

@ -22,6 +22,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata; import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException; import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
@ -36,6 +37,7 @@ import java.util.Set;
* jvanzyl Exp $ * jvanzyl Exp $
*/ */
public class SnapshotTransformation public class SnapshotTransformation
extends AbstractLogEnabled
implements ArtifactTransformation implements ArtifactTransformation
{ {
private WagonManager wagonManager; private WagonManager wagonManager;
@ -69,6 +71,7 @@ public class SnapshotTransformation
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e ); throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
} }
String version = localMetadata.constructVersion();
if ( !alreadyResolved( artifact ) ) if ( !alreadyResolved( artifact ) )
{ {
boolean foundRemote = false; boolean foundRemote = false;
@ -76,12 +79,14 @@ public class SnapshotTransformation
{ {
ArtifactRepository remoteRepository = (ArtifactRepository) i.next(); ArtifactRepository remoteRepository = (ArtifactRepository) i.next();
getLogger().info(
artifact.getArtifactId() + ": checking for updates from " + remoteRepository.getId() );
SnapshotArtifactMetadata remoteMetadata = SnapshotArtifactMetadata.retrieveFromRemoteRepository( SnapshotArtifactMetadata remoteMetadata = SnapshotArtifactMetadata.retrieveFromRemoteRepository(
artifact, remoteRepository, wagonManager ); artifact, remoteRepository, wagonManager );
if ( remoteMetadata.compareTo( localMetadata ) > 0 ) if ( remoteMetadata.compareTo( localMetadata ) > 0 )
{ {
// TODO: investigate transforming this in place, in which case resolve can return void
artifact.setRepository( remoteRepository ); artifact.setRepository( remoteRepository );
localMetadata = remoteMetadata; localMetadata = remoteMetadata;
@ -94,9 +99,26 @@ public class SnapshotTransformation
artifact.addMetadata( localMetadata ); artifact.addMetadata( localMetadata );
} }
if ( getLogger().isInfoEnabled() )
{
if ( !version.equals( artifact.getBaseVersion() ) )
{
String message = artifact.getArtifactId() + ": resolved to version " + version;
if ( foundRemote )
{
message += " from repository " + artifact.getRepository().getId();
}
else
{
message += " from local repository";
}
getLogger().info( message );
}
}
resolvedArtifactCache.add( getCacheKey( artifact ) ); resolvedArtifactCache.add( getCacheKey( artifact ) );
} }
artifact.setVersion( localMetadata.constructVersion() ); artifact.setVersion( version );
} }
} }
@ -114,14 +136,6 @@ public class SnapshotTransformation
public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
{ {
// Nothing to do // Nothing to do
/* TODO: remove
if ( isSnapshot( artifact ) )
{
// only store the version-local.txt file for POMs as every file has an associated POM
ArtifactMetadata metadata = SnapshotArtifactMetadata.createLocalSnapshotMetadata( artifact );
artifact.addMetadata( metadata );
}
*/
} }
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository ) public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )