Search in sources :

Example 1 with IvyNodeBlacklist

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);
    }
}
Also used : RestartResolveProcess(org.apache.ivy.core.resolve.RestartResolveProcess) IvyNodeBlacklist(org.apache.ivy.core.resolve.IvyNodeBlacklist) EvictionData(org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData) IvyNode(org.apache.ivy.core.resolve.IvyNode) Stack(java.util.Stack)

Example 2 with IvyNodeBlacklist

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());
    }
}
Also used : ResolveData(org.apache.ivy.core.resolve.ResolveData) IvyNodeBlacklist(org.apache.ivy.core.resolve.IvyNodeBlacklist) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) IvyNode(org.apache.ivy.core.resolve.IvyNode) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 3 with IvyNodeBlacklist

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;
}
Also used : Caller(org.apache.ivy.core.resolve.IvyNodeCallers.Caller) IvyNodeBlacklist(org.apache.ivy.core.resolve.IvyNodeBlacklist) ArrayList(java.util.ArrayList) IvyNode(org.apache.ivy.core.resolve.IvyNode)

Aggregations

IvyNode (org.apache.ivy.core.resolve.IvyNode)3 IvyNodeBlacklist (org.apache.ivy.core.resolve.IvyNodeBlacklist)3 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Stack (java.util.Stack)1 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)1 Caller (org.apache.ivy.core.resolve.IvyNodeCallers.Caller)1 EvictionData (org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData)1 ResolveData (org.apache.ivy.core.resolve.ResolveData)1 RestartResolveProcess (org.apache.ivy.core.resolve.RestartResolveProcess)1