Skip to content

Commit

Permalink
Add more evenst to Maven ResolutionEventListener
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Jan 17, 2024
1 parent 82d57a4 commit 3a1a8fc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ public MavenMetadata downloadMetadata(GroupArtifactVersion gav, @Nullable Resolv
throw new MavenDownloadingException("Missing group id.", null, gav);
}

ctx.getResolutionListener().downloadMetadata(gav);

Timer.Sample sample = Timer.start();
Timer.Builder timer = Timer.builder("rewrite.maven.download").tag("type", "metadata");

Expand Down Expand Up @@ -457,6 +459,8 @@ public Pom download(GroupArtifactVersion gav,
throw new MavenDownloadingException("Group id, artifact id, or version are missing.", null, gav);
}

ctx.getResolutionListener().download(gav);

// The pom being examined might be from a remote repository or a local filesystem.
// First try to match the requested download with one of the project POMs.
final Pom projectPomWithResolvedVersion = projectPomsByGav.get(gav);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,41 @@

@SuppressWarnings("unused")
public interface ResolutionEventListener {
ResolutionEventListener NOOP = new ResolutionEventListener() {};
ResolutionEventListener NOOP = new ResolutionEventListener() {
};

default void clear() {
}

default void downloadMetadata(GroupArtifactVersion gav) {
}

default void download(GroupArtifactVersion gav) {
}

default void downloadSuccess(ResolvedGroupArtifactVersion gav, @Nullable ResolvedPom containing) {
}

/**
*
* @param gav - GAV coordinate of the dependency which failed to download
* @param gav - GAV coordinate of the dependency which failed to download
* @param attemptedUris - The URIs which were attempted, in the order they were attempted, before resolution was determined to have failed
* @param containing - The pom containing the dependency which failed to resolve, if resolution was attempted from such a context
* @param containing - The pom containing the dependency which failed to resolve, if resolution was attempted from such a context
*/
default void downloadError(GroupArtifactVersion gav, List<String> attemptedUris, @Nullable Pom containing) {
}

default void parent(Pom parent, Pom containing) {
}

default void dependency(Scope scope, ResolvedDependency resolvedDependency, ResolvedPom containing) {
}

default void bomImport(ResolvedGroupArtifactVersion gav, Pom containing) {
}

default void property(String key, String value, Pom containing) {
}

default void dependencyManagement(ManagedDependency dependencyManagement, Pom containing) {
}

Expand Down

0 comments on commit 3a1a8fc

Please sign in to comment.