Skip to content

Commit

Permalink
Log maven resolution exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
spyrkob committed Apr 10, 2024
1 parent 64c28fd commit d0dccab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ VersionRangeResult attemptResolveMetadata(java.util.function.Supplier<VersionRan
while (true) {
final VersionRangeResult versionRangeResult = supplier.get();

if (LOG.isDebugEnabled()) {
for (Exception exception : versionRangeResult.getExceptions()) {
LOG.debug(String.format("Error resolving maven artifact %s: %s", versionRangeResult.getRequest().getArtifact(),exception.getMessage()),
exception);
}
}

final Optional<Exception> transferException = versionRangeResult.getExceptions().stream()
.filter(e -> e.getClass().equals(MetadataTransferException.class))
.findFirst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ public File resolveArtifact(String groupId, String artifactId, String extension,

return retryingResolver.attemptResolve(()->{
final ArtifactResult artifactResult = system.resolveArtifact(session, request);
for (Exception exception : artifactResult.getExceptions()) {
LOG.info("Error resolving maven artifact: " + artifactResult.getRequest().getArtifact() + ": " + exception.getMessage(), exception);
if (LOG.isDebugEnabled()) {
for (Exception exception : artifactResult.getExceptions()) {
LOG.debug(String.format("Error resolving maven artifact %s: %s", artifactResult.getRequest().getArtifact(),exception.getMessage()), exception);
}
}
return List.of(artifactResult.getArtifact().getFile());
},
Expand All @@ -215,6 +217,13 @@ public List<File> resolveArtifacts(List<ArtifactCoordinate> coordinates) throws

final RetryHandler.Supplier artifactQuery = () -> {
final List<ArtifactResult> artifactResults = system.resolveArtifacts(session, requests);
for (ArtifactResult artifactResult : artifactResults) {
if (LOG.isDebugEnabled()) {
for (Exception exception : artifactResult.getExceptions()) {
LOG.debug(String.format("Error resolving maven artifact %s: %s", artifactResult.getRequest().getArtifact(), exception.getMessage()), exception);
}
}
}
// results are in the same order as requests
return artifactResults.stream()
.map(ArtifactResult::getArtifact)
Expand Down Expand Up @@ -323,6 +332,16 @@ private List<MetadataResult> getMavenMetadata(String groupId, String artifactId)
return metadataRequest;
}).collect(Collectors.toList());
final List<MetadataResult> metadataResults = system.resolveMetadata(session, requests);

if (LOG.isDebugEnabled()) {
for (MetadataResult metadataResult : metadataResults) {
if (metadataResult.getException() != null) {
LOG.debug(String.format("Error resolving maven artifact %s:%s %s", groupId, artifactId, metadataResult.getException().getMessage()),
metadataResult.getException());
}
}
}

return metadataResults;
}

Expand Down

0 comments on commit d0dccab

Please sign in to comment.