1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.internal.aether;
20
21 import java.io.FileNotFoundException;
22
23 import org.eclipse.aether.AbstractRepositoryListener;
24 import org.eclipse.aether.RepositoryEvent;
25 import org.eclipse.aether.transfer.MetadataNotFoundException;
26 import org.slf4j.Logger;
27
28
29
30 class LoggingRepositoryListener extends AbstractRepositoryListener {
31
32 private final Logger logger;
33
34 LoggingRepositoryListener(Logger logger) {
35 this.logger = logger;
36 }
37
38 @Override
39 public void artifactInstalling(RepositoryEvent event) {
40 logger.info("Installing {} to {}", event.getArtifact().getFile(), event.getFile());
41 }
42
43 @Override
44 public void metadataInstalling(RepositoryEvent event) {
45 logger.debug("Installing {} to {}", event.getMetadata(), event.getFile());
46 }
47
48 @Override
49 public void metadataResolved(RepositoryEvent event) {
50 Exception e = event.getException();
51 if (e != null) {
52 if (e instanceof MetadataNotFoundException) {
53 logger.debug(e.getMessage());
54 } else if (logger.isDebugEnabled()) {
55 logger.warn(e.getMessage(), e);
56 } else {
57 logger.warn(e.getMessage());
58 }
59 }
60 }
61
62 @Override
63 public void metadataInvalid(RepositoryEvent event) {
64 Exception exception = event.getException();
65
66 Object metadata;
67 if (event.getMetadata().getFile() != null) {
68 metadata = event.getMetadata().getFile();
69 } else {
70 metadata = event.getMetadata();
71 }
72
73 String errorType = " is invalid";
74 if (exception instanceof FileNotFoundException) {
75 errorType = " is inaccessible";
76 }
77
78 String msg = "";
79 if (exception != null) {
80 msg = ": " + exception.getMessage();
81 }
82
83 if (logger.isDebugEnabled()) {
84 logger.warn("The metadata {} {}{}", metadata, errorType, msg, exception);
85 } else {
86 logger.warn("The metadata {} {}{}", metadata, errorType, msg);
87 }
88 }
89
90 @Override
91 public void artifactDescriptorInvalid(RepositoryEvent event) {
92
93 logger.warn(
94 "The POM for {} is invalid, transitive dependencies (if any) will not be available: {}",
95 event.getArtifact(),
96 event.getException().getMessage());
97 }
98
99 @Override
100 public void artifactDescriptorMissing(RepositoryEvent event) {
101 logger.warn("The POM for {} is missing, no dependency information available", event.getArtifact());
102 }
103 }