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      public void artifactDeployed(RepositoryEvent event) {
39          println("artifactDeployed", event.getArtifact() + " to " + event.getRepository());
40      }
41  
42      public void artifactDeploying(RepositoryEvent event) {
43          println("artifactDeploying", event.getArtifact() + " to " + event.getRepository());
44      }
45  
46      public void artifactDescriptorInvalid(RepositoryEvent event) {
47          println(
48                  "artifactDescriptorInvalid",
49                  "for " + event.getArtifact() + ": " + event.getException().getMessage());
50      }
51  
52      public void artifactDescriptorMissing(RepositoryEvent event) {
53          println("artifactDescriptorMissing", "for " + event.getArtifact());
54      }
55  
56      public void artifactInstalled(RepositoryEvent event) {
57          println("artifactInstalled", event.getArtifact() + " to " + event.getFile());
58      }
59  
60      public void artifactInstalling(RepositoryEvent event) {
61          println("artifactInstalling", event.getArtifact() + " to " + event.getFile());
62      }
63  
64      public void artifactResolved(RepositoryEvent event) {
65          println("artifactResolved", event.getArtifact() + " from " + event.getRepository());
66      }
67  
68      public void artifactDownloading(RepositoryEvent event) {
69          println("artifactDownloading", event.getArtifact() + " from " + event.getRepository());
70      }
71  
72      public void artifactDownloaded(RepositoryEvent event) {
73          println("artifactDownloaded", event.getArtifact() + " from " + event.getRepository());
74      }
75  
76      public void artifactResolving(RepositoryEvent event) {
77          println("artifactResolving", event.getArtifact().toString());
78      }
79  
80      public void metadataDeployed(RepositoryEvent event) {
81          println("metadataDeployed", event.getMetadata() + " to " + event.getRepository());
82      }
83  
84      public void metadataDeploying(RepositoryEvent event) {
85          println("metadataDeploying", event.getMetadata() + " to " + event.getRepository());
86      }
87  
88      public void metadataInstalled(RepositoryEvent event) {
89          println("metadataInstalled", event.getMetadata() + " to " + event.getFile());
90      }
91  
92      public void metadataInstalling(RepositoryEvent event) {
93          println("metadataInstalling", event.getMetadata() + " to " + event.getFile());
94      }
95  
96      public void metadataInvalid(RepositoryEvent event) {
97          println("metadataInvalid", event.getMetadata().toString());
98      }
99  
100     public void metadataResolved(RepositoryEvent event) {
101         println("metadataResolved", event.getMetadata() + " from " + event.getRepository());
102     }
103 
104     public void metadataResolving(RepositoryEvent event) {
105         println("metadataResolving", event.getMetadata() + " from " + event.getRepository());
106     }
107 
108     private void println(String event, String message) {
109         out.println("Aether Repository - " + event + ": " + message);
110     }
111 }