Class AbstractDependencyManager
- All Implemented Interfaces:
DependencyManager
- Direct Known Subclasses:
ClassicDependencyManager
,DefaultDependencyManager
,TransitiveDependencyManager
This implementation is Maven specific, as it works hand-in-hand along with Maven ModelBuilder. While model builder handles dependency management in the context of single POM (inheritance, imports, etc.), this implementation carries in-lineage modifications based on previously recorded dependency management rules sourced from ascendants while building the dependency graph. Root sourced management rules are special, in a way they are always applied, while en-route collected ones are carefully applied to proper descendants only, to not override work done by model builder already.
Details: Model builder handles version, scope from own dependency management (think "effective POM"). On the other hand it does not handle optional for example. System paths are aligned across whole graph, making sure there is same system path used by same dependency. Finally, exclusions (exclusions are additional information not effective or applied in same POM) are always applied. This implementation makes sure, that version and scope are not applied onto same node that actually provided the rules, to no override work that ModelBuilder did. It achieves this goal by tracking "depth" for each collected rule and ignoring rules coming from same depth as processed dependency node is.
Note for future: the field managedLocalPaths
is intentionally left out of hash/equals, with
reason explained above.
Implementation note for all managers extending this class: this class maintains "path" (list of parent managers)
and "depth". Depth 0
is basically used as "factory" on session; is the instance created during session
creation and is usually empty (just parameterized). Depth 1 is the current collection "root", depth 2
are direct dependencies, depth 3 first level of transitive dependencies of direct dependencies and so on. Hence, on
depth 1 (the collection root, initialized with management possibly as well) parent will be always the empty "factory"
instance, and we need special handling: "apply onto itself". This does not stand on depth > 1.
- Since:
- 2.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Wrapper class for collection to memoize hash code.protected static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final int
protected final int
protected final int
protected final MMap
<AbstractDependencyManager.Key, AbstractDependencyManager.Holder<Collection<Exclusion>>> protected final MMap
<AbstractDependencyManager.Key, String> protected final MMap
<AbstractDependencyManager.Key, Boolean> protected final MMap
<AbstractDependencyManager.Key, String> protected final MMap
<AbstractDependencyManager.Key, String> protected final ArrayList
<AbstractDependencyManager> protected final SystemDependencyScope
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractDependencyManager
(int deriveUntil, int applyFrom, ScopeManager scopeManager) protected
AbstractDependencyManager
(ArrayList<AbstractDependencyManager> path, int depth, int deriveUntil, int applyFrom, MMap<AbstractDependencyManager.Key, String> managedVersions, MMap<AbstractDependencyManager.Key, String> managedScopes, MMap<AbstractDependencyManager.Key, Boolean> managedOptionals, MMap<AbstractDependencyManager.Key, String> managedLocalPaths, MMap<AbstractDependencyManager.Key, AbstractDependencyManager.Holder<Collection<Exclusion>>> managedExclusions, SystemDependencyScope systemDependencyScope) -
Method Summary
Modifier and TypeMethodDescriptionDerives a dependency manager for the specified collection context.boolean
int
hashCode()
protected boolean
Returnstrue
if current dependency should be managed according to so far collected/derived rules.protected boolean
Returnstrue
if current context should be factored in (collected/derived).manageDependency
(Dependency dependency) Applies dependency management to the specified dependency.protected abstract DependencyManager
newInstance
(MMap<AbstractDependencyManager.Key, String> managedVersions, MMap<AbstractDependencyManager.Key, String> managedScopes, MMap<AbstractDependencyManager.Key, Boolean> managedOptionals, MMap<AbstractDependencyManager.Key, String> managedLocalPaths, MMap<AbstractDependencyManager.Key, AbstractDependencyManager.Holder<Collection<Exclusion>>> managedExclusions)
-
Field Details
-
path
-
depth
-
deriveUntil
-
applyFrom
-
managedVersions
-
managedScopes
-
managedOptionals
-
managedLocalPaths
-
managedExclusions
-
systemDependencyScope
-
-
Constructor Details
-
AbstractDependencyManager
-
AbstractDependencyManager
protected AbstractDependencyManager(ArrayList<AbstractDependencyManager> path, int depth, int deriveUntil, int applyFrom, MMap<AbstractDependencyManager.Key, String> managedVersions, MMap<AbstractDependencyManager.Key, String> managedScopes, MMap<AbstractDependencyManager.Key, Boolean> managedOptionals, MMap<AbstractDependencyManager.Key, String> managedLocalPaths, MMap<AbstractDependencyManager.Key, AbstractDependencyManager.Holder<Collection<Exclusion>>> managedExclusions, SystemDependencyScope systemDependencyScope)
-
-
Method Details
-
newInstance
protected abstract DependencyManager newInstance(MMap<AbstractDependencyManager.Key, String> managedVersions, MMap<AbstractDependencyManager.Key, String> managedScopes, MMap<AbstractDependencyManager.Key, Boolean> managedOptionals, MMap<AbstractDependencyManager.Key, String> managedLocalPaths, MMap<AbstractDependencyManager.Key, AbstractDependencyManager.Holder<Collection<Exclusion>>> managedExclusions) -
deriveChildManager
Description copied from interface:DependencyManager
Derives a dependency manager for the specified collection context. When calculating the child manager, implementors are strongly advised to simply return the current instance if nothing changed to help save memory.- Specified by:
deriveChildManager
in interfaceDependencyManager
- Parameters:
context
- The dependency collection context, must not benull
.- Returns:
- The dependency manager for the dependencies of the target node or
null
if dependency management should no longer be applied.
-
manageDependency
Description copied from interface:DependencyManager
Applies dependency management to the specified dependency.- Specified by:
manageDependency
in interfaceDependencyManager
- Parameters:
dependency
- The dependency to manage, must not benull
.- Returns:
- The management update to apply to the dependency or
null
if the dependency is not managed at all.
-
isDerived
Returnstrue
if current context should be factored in (collected/derived). -
isApplied
Returnstrue
if current dependency should be managed according to so far collected/derived rules. -
equals
-
hashCode
-