From b03435f9e1ccc3f79c609defed5f2a731271dbdd Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Wed, 30 Mar 2005 01:17:34 +0000 Subject: [PATCH] improve reporting git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163710 13f79535-47bb-0310-9956-ffa450edef68 --- .../artifact/manager/DefaultWagonManager.java | 9 ++--- .../transform/SnapshotTransformation.java | 34 +++++++++++++------ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java b/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java index 1c33fdc432..411c7f3505 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java @@ -211,7 +211,7 @@ public class DefaultWagonManager 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 ) @@ -228,10 +228,12 @@ public class DefaultWagonManager 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 { Wagon wagon; @@ -255,7 +257,6 @@ public class DefaultWagonManager //wagon.addTransferListener( md5SumObserver ); - // TODO: probably don't want this on metadata... if ( downloadMonitor != null ) { wagon.addTransferListener( downloadMonitor ); diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java index 809adfe5d4..b9ed766954 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java @@ -22,6 +22,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException; +import org.codehaus.plexus.logging.AbstractLogEnabled; import java.io.IOException; import java.util.HashSet; @@ -36,6 +37,7 @@ import java.util.Set; * jvanzyl Exp $ */ public class SnapshotTransformation + extends AbstractLogEnabled implements ArtifactTransformation { private WagonManager wagonManager; @@ -69,6 +71,7 @@ public class SnapshotTransformation throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e ); } + String version = localMetadata.constructVersion(); if ( !alreadyResolved( artifact ) ) { boolean foundRemote = false; @@ -76,12 +79,14 @@ public class SnapshotTransformation { ArtifactRepository remoteRepository = (ArtifactRepository) i.next(); + getLogger().info( + artifact.getArtifactId() + ": checking for updates from " + remoteRepository.getId() ); + SnapshotArtifactMetadata remoteMetadata = SnapshotArtifactMetadata.retrieveFromRemoteRepository( artifact, remoteRepository, wagonManager ); if ( remoteMetadata.compareTo( localMetadata ) > 0 ) { - // TODO: investigate transforming this in place, in which case resolve can return void artifact.setRepository( remoteRepository ); localMetadata = remoteMetadata; @@ -94,9 +99,26 @@ public class SnapshotTransformation 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 ) ); } - artifact.setVersion( localMetadata.constructVersion() ); + artifact.setVersion( version ); } } @@ -114,14 +136,6 @@ public class SnapshotTransformation public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) { // 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 )