org.apache.maven.shared.dependency.tree
Class DependencyTreeResolutionListener

java.lang.Object
  extended by org.apache.maven.shared.dependency.tree.DependencyTreeResolutionListener
All Implemented Interfaces:
org.apache.maven.artifact.resolver.ResolutionListener, org.apache.maven.artifact.resolver.ResolutionListenerForDepMgmt

public class DependencyTreeResolutionListener
extends java.lang.Object
implements org.apache.maven.artifact.resolver.ResolutionListener, org.apache.maven.artifact.resolver.ResolutionListenerForDepMgmt

An artifact resolution listener that constructs a dependency tree.

Version:
$Id: DependencyTreeResolutionListener.java 576969 2007-09-18 16:11:29Z markh $
Author:
Edwin Punzalan, Mark Hobson

Field Summary
private  DependencyNode currentNode
          The dependency node currently being processed by this listener.
private  org.codehaus.plexus.logging.Logger logger
          The log to write debug messages to.
private  java.util.Map managedScopes
          Map < String replacementId, String premanaged scope >
private  java.util.Map managedVersions
          Map < String replacementId, String premanaged version >
private  java.util.Map nodesByArtifact
          A map of dependency nodes by their attached artifact.
private  java.util.Stack parentNodes
          The parent dependency nodes of the current dependency node.
private  DependencyNode rootNode
          The root dependency node of the computed dependency tree.
 
Fields inherited from interface org.apache.maven.artifact.resolver.ResolutionListener
FINISH_PROCESSING_CHILDREN, INCLUDE_ARTIFACT, MANAGE_ARTIFACT, MANAGE_ARTIFACT_SCOPE, MANAGE_ARTIFACT_VERSION, OMIT_FOR_CYCLE, OMIT_FOR_NEARER, PROCESS_CHILDREN, RESTRICT_RANGE, ROLE, SELECT_VERSION_FROM_RANGE, TEST_ARTIFACT, UPDATE_SCOPE, UPDATE_SCOPE_CURRENT_POM
 
Constructor Summary
DependencyTreeResolutionListener(org.codehaus.plexus.logging.Logger logger)
          Creates a new dependency tree resolution listener that writes to the specified log.
 
Method Summary
(package private)  DependencyNode addNode(org.apache.maven.artifact.Artifact artifact)
          Creates a new dependency node for the specified artifact, appends it to the current parent dependency node and puts it into the dependency node cache.
private  DependencyNode createNode(org.apache.maven.artifact.Artifact artifact)
          Creates a new dependency node for the specified artifact and appends it to the current parent dependency node.
 void endProcessChildren(org.apache.maven.artifact.Artifact artifact)
           
private  void flushDependencyManagement(DependencyNode node)
          Updates the specified node with any dependency management information cached in prior manageArtifact calls.
private  DependencyNode getNode(org.apache.maven.artifact.Artifact artifact)
          Gets the dependency node for the specified artifact from the dependency node cache.
 java.util.Collection getNodes()
          Deprecated. As of 1.1, use a CollectingDependencyNodeVisitor on the root dependency node
 DependencyNode getRootNode()
          Gets the root dependency node of the computed dependency tree.
 void includeArtifact(org.apache.maven.artifact.Artifact artifact)
           
private  boolean isCurrentNodeIncluded()
          Gets whether the all the ancestors of the dependency node currently being processed by this listener have an included state.
private  void log(java.lang.String message)
          Writes the specified message to the log at debug level with indentation for the current node's depth.
 void manageArtifact(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.Artifact replacement)
           
 void manageArtifactScope(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.Artifact replacement)
           
 void manageArtifactVersion(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.Artifact replacement)
           
 void omitForCycle(org.apache.maven.artifact.Artifact artifact)
           
 void omitForNearer(org.apache.maven.artifact.Artifact omitted, org.apache.maven.artifact.Artifact kept)
           
private  void removeNode(org.apache.maven.artifact.Artifact artifact)
          Removes the dependency node for the specified artifact from the dependency node cache.
 void restrictRange(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.Artifact replacement, org.apache.maven.artifact.versioning.VersionRange versionRange)
           
 void selectVersionFromRange(org.apache.maven.artifact.Artifact artifact)
           
 void startProcessChildren(org.apache.maven.artifact.Artifact artifact)
           
 void testArtifact(org.apache.maven.artifact.Artifact artifact)
           
 void updateScope(org.apache.maven.artifact.Artifact artifact, java.lang.String scope)
           
 void updateScopeCurrentPom(org.apache.maven.artifact.Artifact artifact, java.lang.String scopeIgnored)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private final org.codehaus.plexus.logging.Logger logger
The log to write debug messages to.


parentNodes

private final java.util.Stack parentNodes
The parent dependency nodes of the current dependency node.


nodesByArtifact

private final java.util.Map nodesByArtifact
A map of dependency nodes by their attached artifact.


rootNode

private DependencyNode rootNode
The root dependency node of the computed dependency tree.


currentNode

private DependencyNode currentNode
The dependency node currently being processed by this listener.


managedVersions

private java.util.Map managedVersions
Map < String replacementId, String premanaged version >


managedScopes

private java.util.Map managedScopes
Map < String replacementId, String premanaged scope >

Constructor Detail

DependencyTreeResolutionListener

public DependencyTreeResolutionListener(org.codehaus.plexus.logging.Logger logger)
Creates a new dependency tree resolution listener that writes to the specified log.

Parameters:
logger - the log to write debug messages to
Method Detail

testArtifact

public void testArtifact(org.apache.maven.artifact.Artifact artifact)
Specified by:
testArtifact in interface org.apache.maven.artifact.resolver.ResolutionListener

startProcessChildren

public void startProcessChildren(org.apache.maven.artifact.Artifact artifact)
Specified by:
startProcessChildren in interface org.apache.maven.artifact.resolver.ResolutionListener

endProcessChildren

public void endProcessChildren(org.apache.maven.artifact.Artifact artifact)
Specified by:
endProcessChildren in interface org.apache.maven.artifact.resolver.ResolutionListener

includeArtifact

public void includeArtifact(org.apache.maven.artifact.Artifact artifact)
Specified by:
includeArtifact in interface org.apache.maven.artifact.resolver.ResolutionListener

omitForNearer

public void omitForNearer(org.apache.maven.artifact.Artifact omitted,
                          org.apache.maven.artifact.Artifact kept)
Specified by:
omitForNearer in interface org.apache.maven.artifact.resolver.ResolutionListener

updateScope

public void updateScope(org.apache.maven.artifact.Artifact artifact,
                        java.lang.String scope)
Specified by:
updateScope in interface org.apache.maven.artifact.resolver.ResolutionListener

manageArtifact

public void manageArtifact(org.apache.maven.artifact.Artifact artifact,
                           org.apache.maven.artifact.Artifact replacement)
Specified by:
manageArtifact in interface org.apache.maven.artifact.resolver.ResolutionListener

omitForCycle

public void omitForCycle(org.apache.maven.artifact.Artifact artifact)
Specified by:
omitForCycle in interface org.apache.maven.artifact.resolver.ResolutionListener

updateScopeCurrentPom

public void updateScopeCurrentPom(org.apache.maven.artifact.Artifact artifact,
                                  java.lang.String scopeIgnored)
Specified by:
updateScopeCurrentPom in interface org.apache.maven.artifact.resolver.ResolutionListener

selectVersionFromRange

public void selectVersionFromRange(org.apache.maven.artifact.Artifact artifact)
Specified by:
selectVersionFromRange in interface org.apache.maven.artifact.resolver.ResolutionListener

restrictRange

public void restrictRange(org.apache.maven.artifact.Artifact artifact,
                          org.apache.maven.artifact.Artifact replacement,
                          org.apache.maven.artifact.versioning.VersionRange versionRange)
Specified by:
restrictRange in interface org.apache.maven.artifact.resolver.ResolutionListener

manageArtifactVersion

public void manageArtifactVersion(org.apache.maven.artifact.Artifact artifact,
                                  org.apache.maven.artifact.Artifact replacement)
Specified by:
manageArtifactVersion in interface org.apache.maven.artifact.resolver.ResolutionListenerForDepMgmt

manageArtifactScope

public void manageArtifactScope(org.apache.maven.artifact.Artifact artifact,
                                org.apache.maven.artifact.Artifact replacement)
Specified by:
manageArtifactScope in interface org.apache.maven.artifact.resolver.ResolutionListenerForDepMgmt

getNodes

public java.util.Collection getNodes()
Deprecated. As of 1.1, use a CollectingDependencyNodeVisitor on the root dependency node

Gets a list of all dependency nodes in the computed dependency tree.

Returns:
a list of dependency nodes

getRootNode

public DependencyNode getRootNode()
Gets the root dependency node of the computed dependency tree.

Returns:
the root node

log

private void log(java.lang.String message)
Writes the specified message to the log at debug level with indentation for the current node's depth.

Parameters:
message - the message to write to the log

createNode

private DependencyNode createNode(org.apache.maven.artifact.Artifact artifact)
Creates a new dependency node for the specified artifact and appends it to the current parent dependency node.

Parameters:
artifact - the attached artifact for the new dependency node
Returns:
the new dependency node

addNode

DependencyNode addNode(org.apache.maven.artifact.Artifact artifact)
Creates a new dependency node for the specified artifact, appends it to the current parent dependency node and puts it into the dependency node cache.

Parameters:
artifact - the attached artifact for the new dependency node
Returns:
the new dependency node

getNode

private DependencyNode getNode(org.apache.maven.artifact.Artifact artifact)
Gets the dependency node for the specified artifact from the dependency node cache.

Parameters:
artifact - the artifact to find the dependency node for
Returns:
the dependency node, or null if the specified artifact has no corresponding dependency node

removeNode

private void removeNode(org.apache.maven.artifact.Artifact artifact)
Removes the dependency node for the specified artifact from the dependency node cache.

Parameters:
artifact - the artifact to remove the dependency node for

isCurrentNodeIncluded

private boolean isCurrentNodeIncluded()
Gets whether the all the ancestors of the dependency node currently being processed by this listener have an included state.

Returns:
true if all the ancestors of the current dependency node have a state of INCLUDED

flushDependencyManagement

private void flushDependencyManagement(DependencyNode node)
Updates the specified node with any dependency management information cached in prior manageArtifact calls.

Parameters:
node - the node to update