Class AbstractDependencyManager

java.lang.Object
org.eclipse.aether.util.graph.manager.AbstractDependencyManager
All Implemented Interfaces:
org.eclipse.aether.collection.DependencyManager
Direct Known Subclasses:
ClassicDependencyManager, DefaultDependencyManager, TransitiveDependencyManager

public abstract class AbstractDependencyManager extends Object implements org.eclipse.aether.collection.DependencyManager
A dependency manager support class for Maven-specific dependency graph management.

Overview

This implementation works in conjunction with Maven ModelBuilder to handle dependency management across the dependency graph. While ModelBuilder manages dependencies within a single POM context (inheritance, imports), this class applies lineage-based modifications based on previously recorded dependency management rules sourced from ancestors while building the dependency graph. Root-sourced management rules are special, in that they are always applied, while rules collected during traversal are carefully applied to proper descendants only, to not override work done by ModelBuilder already.

Managed Properties

  • Version & Scope: Handled by ModelBuilder for own dependency management (think "effective POM"). This implementation ensures these are not applied to the same node that provided the rules, to not override ModelBuilder's work.
  • Optional: Not handled by ModelBuilder; managed here.
  • System Paths: Aligned across the entire graph, ensuring the same system path is used by the same dependency.
  • Exclusions: Always applied as additional information (not effective or applied in the same POM).

Depth-Based Rule Application

This implementation achieves proper rule application by tracking "depth" for each collected rule and ignoring rules coming from the same depth as the processed dependency node.

  • Depth 0: Factory instance created during session initialization and parameterized. Collection begins with "derive" operation using root context.
  • Depth 1: Special case for "version", "scope" and "optional" properties. At this level, "apply onto itself" ensures root-defined rules are applied to first-level siblings (which, if managed by ModelBuilder, will be the same, making this a no-op).
  • Depth > 1: "Apply onto itself" is not in effect; only "apply below" is used.

Rule Precedence

Rules are keyed by dependency management entry coordinates (GACE: Group, Artifact, Classifier, Extension - see AbstractDependencyManager.Key) and are recorded only if a rule for the same key did not exist previously. This implements the "nearer (to root) management wins" rule, while root management overrides all.

Managed Bits and Graph Transformations

When a DependencyNode becomes "managed" by any property provided from this manager, DependencyNode.getManagedBits() will carry this information for the given property. Later graph transformations will abstain from modifying these properties of marked nodes (assuming the node already has the property set to what it should have). Sometimes this is unwanted, especially for properties that need to be inherited in the graph (values derived from parent-child context of the actual node, like "scope" or "optional").

Implementation Notes

  • This class maintains a "path" (list of parent managers) and "depth".
  • The field managedLocalPaths is intentionally left out of hash/equals.
  • Each dependency "derives" an instance with its own context to process second-level dependencies and so on.
Since:
2.0.0