Package org.apache.ivy.plugins.conflict
Class LatestCompatibleConflictManager
java.lang.Object
org.apache.ivy.plugins.conflict.AbstractConflictManager
org.apache.ivy.plugins.conflict.LatestConflictManager
org.apache.ivy.plugins.conflict.LatestCompatibleConflictManager
- All Implemented Interfaces:
ConflictManager
,IvySettingsAware
This conflict manager can be used to allow only compatible dependencies to be used together (like
the strict conflict manager), but it has the advantage of using a best effort algorithm to find a
set of compatible dependencies, even if it requires stepping back to older revisions (as long as
they are in the set of compatibility).
Here is an example of what this conflict manager is able to do:
Available Modules:#A;2->{ #B;[1.0,1.5] #C;[2.0,2.5] } #B;1.4->#D;1.5 #B;1.5->#D;2.0 #C;2.5->#D;[1.0,1.6]Result: #B;1.4, #C;2.5, #D;1.5
DetailsThe conflict manager finds that the latest matching version of #B (1.5) depends on a version of #D incompatible with what is expected by the latest matching version of #C. Hence the conflict manager blacklists #B;1.5, and the version range [1.0,1.5] is resolved again to end up with #B;1.4 which depends on #D;1.5, which is fine to work with #C;2.5.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.ivy.plugins.conflict.LatestConflictManager
LatestConflictManager.IvyNodeArtifactInfo, LatestConflictManager.NoConflictResolvedYetException
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Collection<IvyNodeBlacklist>
blackListIncompatibleCaller
(VersionMatcher versionMatcher, IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode, Stack<IvyNode> callerStack) Tries to blacklist exactly one version for all callers paths.private void
blackListIncompatibleCallerAndRestartResolveIfPossible
(IvySettings settings, IvyNode parent, IvyNode selected, IvyNode evicted) void
handleAllBlacklistedRevisions
(DependencyDescriptor dd, Collection<ModuleRevisionId> foundBlacklisted) Method called when all revisions available for a version constraint have been blacklisted, and thus the dependency can't be resolved.private boolean
handleIncompatibleCaller
(Stack<IvyNode> callerStack, IvyNode node, IvyNode callerNode, IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode, Collection<IvyNodeBlacklist> blacklisted, VersionMatcher versionMatcher) private boolean
handleIncompatibleConflict
(IvyNode parent, Collection<IvyNode> conflicts, IvyNode node, IvyNode other) Handles an incompatible conflictprotected void
handleUnsolvableConflict
(IvyNode parent, Collection<IvyNode> conflicts, IvyNode node1, IvyNode node2) resolveConflicts
(IvyNode parent, Collection<IvyNode> conflicts) Resolves the eventual conflicts found in the given collection of IvyNode.toString()
Methods inherited from class org.apache.ivy.plugins.conflict.LatestConflictManager
getStrategy, setLatest, setStrategy, toArtifactInfo
Methods inherited from class org.apache.ivy.plugins.conflict.AbstractConflictManager
getName, getSettings, setName, setSettings
-
Constructor Details
-
LatestCompatibleConflictManager
public LatestCompatibleConflictManager() -
LatestCompatibleConflictManager
-
-
Method Details
-
resolveConflicts
Description copied from interface:ConflictManager
Resolves the eventual conflicts found in the given collection of IvyNode. This method return a Collection of IvyNode which have not been evicted. The given conflicts Collection contains at least one IvyNode. This method can be called with IvyNodes which are not yet loaded. If this conflict manager is not able to resolve conflicts with the current data found in the IvyNodes and need them to be fully loaded, it will return null to indicate that no conflict resolution has been done.- Specified by:
resolveConflicts
in interfaceConflictManager
- Overrides:
resolveConflicts
in classLatestConflictManager
- Parameters:
parent
- the ivy node parent for which the conflict is to be resolvedconflicts
- the collection of IvyNode to check for conflicts- Returns:
- a Collection of IvyNode which have not been evicted, or null if conflict management resolution is not possible yet
-
handleIncompatibleConflict
private boolean handleIncompatibleConflict(IvyNode parent, Collection<IvyNode> conflicts, IvyNode node, IvyNode other) Handles an incompatible conflictAn incompatible conflicts is handled with this pseudo algorithm:
take latest among two nodes in conflict for all callers if dependency is a version constraint (dynamic) blacklist the mapped version else recurse for all callers if a version constraint has been found restart resolve else throw strict conflict exception
- Parameters:
parent
- the parent node of nodes in conflictconflicts
- all the nodes in conflictnode
- one of the two incompatible nodesother
- the other incompatible node- Returns:
- true if the incompatible conflict has been handled, false otherwise (in which case resolveConflicts should return null)
-
blackListIncompatibleCallerAndRestartResolveIfPossible
private void blackListIncompatibleCallerAndRestartResolveIfPossible(IvySettings settings, IvyNode parent, IvyNode selected, IvyNode evicted) -
handleIncompatibleCaller
private boolean handleIncompatibleCaller(Stack<IvyNode> callerStack, IvyNode node, IvyNode callerNode, IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode, Collection<IvyNodeBlacklist> blacklisted, VersionMatcher versionMatcher) -
blackListIncompatibleCaller
private Collection<IvyNodeBlacklist> blackListIncompatibleCaller(VersionMatcher versionMatcher, IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode, Stack<IvyNode> callerStack) Tries to blacklist exactly one version for all callers paths.- Parameters:
versionMatcher
- the version matcher to use to interpret versionsconflictParent
- the node in which the conflict is occurringselectedNode
- the node in favor of which the conflict is resolvedevictedNode
- the node which will be evicted if we are able to blacklist all pathscallerStack
- ditto- Returns:
- the collection of blacklisting to do, null if a blacklist is not possible in at least one caller path
-
handleUnsolvableConflict
protected void handleUnsolvableConflict(IvyNode parent, Collection<IvyNode> conflicts, IvyNode node1, IvyNode node2) -
handleAllBlacklistedRevisions
public void handleAllBlacklistedRevisions(DependencyDescriptor dd, Collection<ModuleRevisionId> foundBlacklisted) Description copied from interface:ConflictManager
Method called when all revisions available for a version constraint have been blacklisted, and thus the dependency can't be resolved.This will never happen if the conflict manager doesn't blacklist any module, so providing an empty implementation in this case is fine.
- Specified by:
handleAllBlacklistedRevisions
in interfaceConflictManager
- Overrides:
handleAllBlacklistedRevisions
in classAbstractConflictManager
- Parameters:
dd
- the dependency descriptor for which all revisions are blacklisted.foundBlacklisted
- the list of all ModuleRevisionId found which are blacklisted
-
toString
- Overrides:
toString
in classLatestConflictManager
-