diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java b/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java index 05129b7db7..6ad6180a40 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java @@ -97,7 +97,7 @@ public class DefaultArtifactInstaller if ( localRepositoryMaintainer != null ) { LocalRepositoryMaintainerEvent event = - new DefaultLocalRepositoryMaintainerEvent( artifact, destination ); + new DefaultLocalRepositoryMaintainerEvent( localRepository, artifact, destination ); localRepositoryMaintainer.artifactInstalled( event ); } } diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java index 7a56830266..56b33fe389 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java @@ -38,6 +38,9 @@ import org.apache.maven.artifact.repository.metadata.Snapshot; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; +import org.apache.maven.repository.DefaultLocalRepositoryMaintainerEvent; +import org.apache.maven.repository.LocalRepositoryMaintainer; +import org.apache.maven.repository.LocalRepositoryMaintainerEvent; import org.apache.maven.repository.legacy.TransferListenerAdapter; import org.apache.maven.repository.legacy.WagonManager; import org.apache.maven.repository.legacy.metadata.ArtifactMetadata; @@ -85,6 +88,9 @@ public class DefaultArtifactResolver @Requirement private PlexusContainer container; + + @Requirement( optional = true ) + private LocalRepositoryMaintainer localRepositoryMaintainer; public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository, TransferListener resolutionListener ) throws ArtifactResolutionException, ArtifactNotFoundException @@ -176,6 +182,14 @@ public class DefaultArtifactResolver { wagonManager.getArtifact( artifact, remoteRepositories, downloadMonitor, request.isForceUpdate() ); } + + if ( localRepositoryMaintainer != null ) + { + LocalRepositoryMaintainerEvent event = + new DefaultLocalRepositoryMaintainerEvent( localRepository, artifact, null ); + localRepositoryMaintainer.artifactDownloaded( event ); + } + } catch ( ResourceDoesNotExistException e ) { diff --git a/maven-compat/src/main/java/org/apache/maven/repository/DefaultLocalRepositoryMaintainerEvent.java b/maven-compat/src/main/java/org/apache/maven/repository/DefaultLocalRepositoryMaintainerEvent.java index 370a6ecff3..81f6271a83 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/DefaultLocalRepositoryMaintainerEvent.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/DefaultLocalRepositoryMaintainerEvent.java @@ -22,6 +22,7 @@ package org.apache.maven.repository; import java.io.File; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; /** * Describes an event to be consumed by {@link LocalRepositoryMaintainer}. @@ -31,17 +32,24 @@ import org.apache.maven.artifact.Artifact; public class DefaultLocalRepositoryMaintainerEvent implements LocalRepositoryMaintainerEvent { + private ArtifactRepository localRepository; private Artifact artifact; private File file; - public DefaultLocalRepositoryMaintainerEvent( Artifact artifact, File file ) + public DefaultLocalRepositoryMaintainerEvent( ArtifactRepository localRepository, Artifact artifact, File file ) { + this.localRepository = localRepository; this.artifact = artifact; this.file = ( file != null ) ? file : artifact.getFile(); } + public ArtifactRepository getLocalRepository() + { + return localRepository; + } + public String getGroupId() { return artifact.getGroupId(); diff --git a/maven-compat/src/main/java/org/apache/maven/repository/LocalRepositoryMaintainerEvent.java b/maven-compat/src/main/java/org/apache/maven/repository/LocalRepositoryMaintainerEvent.java index ff3ee4b7b7..c4971775fd 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/LocalRepositoryMaintainerEvent.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/LocalRepositoryMaintainerEvent.java @@ -21,6 +21,8 @@ package org.apache.maven.repository; import java.io.File; +import org.apache.maven.artifact.repository.ArtifactRepository; + /** * Describes an event to be consumed by {@link LocalRepositoryMaintainer}. * @@ -29,6 +31,13 @@ import java.io.File; public interface LocalRepositoryMaintainerEvent { + /** + * The local ArtifactRepository instance that generated the event. + * + * @return Source artifact repository, never {@code null}. + */ + ArtifactRepository getLocalRepository(); + /** * The group id of the artifact. * diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java index 4ef9226571..f84a097a16 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java @@ -30,9 +30,6 @@ 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.ArtifactRepositoryPolicy; -import org.apache.maven.repository.DefaultLocalRepositoryMaintainerEvent; -import org.apache.maven.repository.LocalRepositoryMaintainer; -import org.apache.maven.repository.LocalRepositoryMaintainerEvent; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; @@ -76,9 +73,6 @@ public class DefaultWagonManager @Requirement private UpdateCheckManager updateCheckManager; - @Requirement( optional = true ) - private LocalRepositoryMaintainer localRepositoryMaintainer; - // // Retriever // @@ -105,13 +99,6 @@ public class DefaultWagonManager { getRemoteFile( repository, artifact.getFile(), remotePath, downloadMonitor, policy.getChecksumPolicy(), false ); - - if ( localRepositoryMaintainer != null ) - { - LocalRepositoryMaintainerEvent event = - new DefaultLocalRepositoryMaintainerEvent( artifact, null ); - localRepositoryMaintainer.artifactDownloaded( event ); - } } finally {