use of org.apache.ivy.core.resolve.IvyNodeBlacklist in project ant-ivy by apache.
the class LatestCompatibleConflictManager method blackListIncompatibleCallerAndRestartResolveIfPossible.
private void blackListIncompatibleCallerAndRestartResolveIfPossible(IvySettings settings, IvyNode parent, IvyNode selected, IvyNode evicted) {
Stack<IvyNode> callerStack = new Stack<>();
callerStack.push(evicted);
Collection<IvyNodeBlacklist> toBlacklist = blackListIncompatibleCaller(settings.getVersionMatcher(), parent, selected, evicted, callerStack);
if (toBlacklist != null) {
final StringBuilder blacklisted = new StringBuilder();
for (IvyNodeBlacklist blacklist : toBlacklist) {
if (blacklisted.length() > 0) {
blacklisted.append(" ");
}
IvyNode blacklistedNode = blacklist.getBlacklistedNode();
blacklistedNode.blacklist(blacklist);
blacklisted.append(blacklistedNode);
}
String rootModuleConf = parent.getData().getReport().getConfiguration();
evicted.markEvicted(new EvictionData(rootModuleConf, parent, this, Collections.singleton(selected), "with blacklisting of " + blacklisted));
if (settings.debugConflictResolution()) {
Message.debug("evicting " + evicted + " by " + evicted.getEvictedData(rootModuleConf));
}
throw new RestartResolveProcess("trying to handle incompatibilities between " + selected + " and " + evicted);
}
}
use of org.apache.ivy.core.resolve.IvyNodeBlacklist in project ant-ivy by apache.
the class LatestCompatibleConflictManager method handleAllBlacklistedRevisions.
@Override
public void handleAllBlacklistedRevisions(DependencyDescriptor dd, Collection<ModuleRevisionId> foundBlacklisted) {
ResolveData resolveData = IvyContext.getContext().getResolveData();
Collection<IvyNode> blacklisted = new HashSet<>();
for (ModuleRevisionId mrid : foundBlacklisted) {
blacklisted.add(resolveData.getNode(mrid));
}
for (IvyNode node : blacklisted) {
IvyNodeBlacklist bdata = node.getBlacklistData(resolveData.getReport().getConfiguration());
handleUnsolvableConflict(bdata.getConflictParent(), Arrays.asList(bdata.getEvictedNode(), bdata.getSelectedNode()), bdata.getEvictedNode(), bdata.getSelectedNode());
}
}
use of org.apache.ivy.core.resolve.IvyNodeBlacklist in project ant-ivy by apache.
the class LatestCompatibleConflictManager method blackListIncompatibleCaller.
/**
* Tries to blacklist exactly one version for all callers paths.
*
* @param versionMatcher
* the version matcher to use to interpret versions
* @param conflictParent
* the node in which the conflict is occurring
* @param selectedNode
* the node in favor of which the conflict is resolved
* @param evictedNode
* the node which will be evicted if we are able to blacklist all paths
* @param callerStack
* ditto
* @return the collection of blacklisting to do, null if a blacklist is not possible in at least
* one caller path
*/
private Collection<IvyNodeBlacklist> blackListIncompatibleCaller(VersionMatcher versionMatcher, IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode, Stack<IvyNode> callerStack) {
Collection<IvyNodeBlacklist> blacklisted = new ArrayList<>();
IvyNode node = callerStack.peek();
String rootModuleConf = conflictParent.getData().getReport().getConfiguration();
for (Caller caller : node.getCallers(rootModuleConf)) {
IvyNode callerNode = node.findNode(caller.getModuleRevisionId());
if (callerNode.isBlacklisted(rootModuleConf)) {
continue;
}
if (versionMatcher.isDynamic(caller.getAskedDependencyId())) {
blacklisted.add(new IvyNodeBlacklist(conflictParent, selectedNode, evictedNode, node, rootModuleConf));
if (node.isEvicted(rootModuleConf) && !handleIncompatibleCaller(callerStack, node, callerNode, conflictParent, selectedNode, evictedNode, blacklisted, versionMatcher)) {
return null;
}
} else if (!handleIncompatibleCaller(callerStack, node, callerNode, conflictParent, selectedNode, evictedNode, blacklisted, versionMatcher)) {
return null;
}
}
if (blacklisted.isEmpty() && !callerStack.subList(0, callerStack.size() - 1).contains(node)) {
return null;
}
return blacklisted;
}
Aggregations