View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.repository.internal.util;
20  
21  import java.io.PrintStream;
22  
23  import org.eclipse.aether.AbstractRepositoryListener;
24  import org.eclipse.aether.RepositoryEvent;
25  
26  public class ConsoleRepositoryListener extends AbstractRepositoryListener {
27  
28      private PrintStream out;
29  
30      public ConsoleRepositoryListener() {
31          this(null);
32      }
33  
34      public ConsoleRepositoryListener(PrintStream out) {
35          this.out = (out != null) ? out : System.out;
36      }
37  
38      @Override
39      public void artifactDeployed(RepositoryEvent event) {
40          println("artifactDeployed", event.getArtifact() + " to " + event.getRepository());
41      }
42  
43      @Override
44      public void artifactDeploying(RepositoryEvent event) {
45          println("artifactDeploying", event.getArtifact() + " to " + event.getRepository());
46      }
47  
48      @Override
49      public void artifactDescriptorInvalid(RepositoryEvent event) {
50          println(
51                  "artifactDescriptorInvalid",
52                  "for " + event.getArtifact() + ": " + event.getException().getMessage());
53      }
54  
55      @Override
56      public void artifactDescriptorMissing(RepositoryEvent event) {
57          println("artifactDescriptorMissing", "for " + event.getArtifact());
58      }
59  
60      @Override
61      public void artifactInstalled(RepositoryEvent event) {
62          println("artifactInstalled", event.getArtifact() + " to " + event.getFile());
63      }
64  
65      @Override
66      public void artifactInstalling(RepositoryEvent event) {
67          println("artifactInstalling", event.getArtifact() + " to " + event.getFile());
68      }
69  
70      @Override
71      public void artifactResolved(RepositoryEvent event) {
72          println("artifactResolved", event.getArtifact() + " from " + event.getRepository());
73      }
74  
75      @Override
76      public void artifactDownloading(RepositoryEvent event) {
77          println("artifactDownloading", event.getArtifact() + " from " + event.getRepository());
78      }
79  
80      @Override
81      public void artifactDownloaded(RepositoryEvent event) {
82          println("artifactDownloaded", event.getArtifact() + " from " + event.getRepository());
83      }
84  
85      @Override
86      public void artifactResolving(RepositoryEvent event) {
87          println("artifactResolving", event.getArtifact().toString());
88      }
89  
90      @Override
91      public void metadataDeployed(RepositoryEvent event) {
92          println("metadataDeployed", event.getMetadata() + " to " + event.getRepository());
93      }
94  
95      @Override
96      public void metadataDeploying(RepositoryEvent event) {
97          println("metadataDeploying", event.getMetadata() + " to " + event.getRepository());
98      }
99  
100     @Override
101     public void metadataInstalled(RepositoryEvent event) {
102         println("metadataInstalled", event.getMetadata() + " to " + event.getFile());
103     }
104 
105     @Override
106     public void metadataInstalling(RepositoryEvent event) {
107         println("metadataInstalling", event.getMetadata() + " to " + event.getFile());
108     }
109 
110     @Override
111     public void metadataInvalid(RepositoryEvent event) {
112         println("metadataInvalid", event.getMetadata().toString());
113     }
114 
115     @Override
116     public void metadataResolved(RepositoryEvent event) {
117         println("metadataResolved", event.getMetadata() + " from " + event.getRepository());
118     }
119 
120     @Override
121     public void metadataResolving(RepositoryEvent event) {
122         println("metadataResolving", event.getMetadata() + " from " + event.getRepository());
123     }
124 
125     private void println(String event, String message) {
126         out.println("Aether Repository - " + event + ": " + message);
127     }
128 }