KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > artifact > resolver > DebugResolutionListener


1 package org.apache.maven.artifact.resolver;
2
3 /*
4  * Copyright 2001-2005 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * 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, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import org.apache.maven.artifact.Artifact;
20 import org.apache.maven.artifact.versioning.VersionRange;
21 import org.codehaus.plexus.logging.Logger;
22
23 /**
24  * Send resolution events to the debug log.
25  *
26  * @author <a HREF="mailto:brett@apache.org">Brett Porter</a>
27  * @version $Id$
28  */

29 public class DebugResolutionListener
30     implements ResolutionListener
31 {
32     private Logger logger;
33
34     private String JavaDoc indent = "";
35
36     public DebugResolutionListener( Logger logger )
37     {
38         this.logger = logger;
39     }
40
41     public void testArtifact( Artifact node )
42     {
43     }
44
45     public void startProcessChildren( Artifact artifact )
46     {
47         indent += " ";
48     }
49
50     public void endProcessChildren( Artifact artifact )
51     {
52         indent = indent.substring( 2 );
53     }
54
55     public void includeArtifact( Artifact artifact )
56     {
57         logger.debug( indent + artifact + " (selected for " + artifact.getScope() + ")" );
58     }
59
60     public void omitForNearer( Artifact omitted, Artifact kept )
61     {
62         logger.debug( indent + omitted + " (removed - nearer found: " + kept.getVersion() + ")" );
63     }
64
65     public void omitForCycle( Artifact omitted )
66     {
67         logger.debug( indent + omitted + " (removed - causes a cycle in the graph)" );
68     }
69
70     public void updateScopeCurrentPom( Artifact artifact, String JavaDoc scope )
71     {
72         logger.debug( indent + artifact + " (not setting scope to: " + scope + "; local scope " + artifact.getScope() +
73             " wins)" );
74     }
75
76     public void updateScope( Artifact artifact, String JavaDoc scope )
77     {
78         logger.debug( indent + artifact + " (setting scope to: " + scope + ")" );
79     }
80
81     public void selectVersionFromRange( Artifact artifact )
82     {
83         logger.debug( indent + artifact + " (setting version to: " + artifact.getVersion() + " from range: " +
84             artifact.getVersionRange() + ")" );
85     }
86
87     public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange )
88     {
89         logger.debug( indent + artifact + " (range restricted from: " + artifact.getVersionRange() + " and: " +
90             replacement.getVersionRange() + " to: " + newRange + " )" );
91     }
92
93     public void manageArtifact( Artifact artifact, Artifact replacement )
94     {
95         String JavaDoc msg = indent + artifact;
96         msg += " (";
97         if ( replacement.getVersion() != null )
98         {
99             msg += "applying version: " + replacement.getVersion() + ";";
100         }
101         if ( replacement.getScope() != null )
102         {
103             msg += "applying scope: " + replacement.getScope();
104         }
105         msg += ")";
106         logger.debug( msg );
107     }
108 }
109
Popular Tags