Search in sources :

Example 1 with StrictVersionConstraints

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.strict.StrictVersionConstraints in project gradle by gradle.

the class NodeState method getEndorsedStrictVersions.

private StrictVersionConstraints getEndorsedStrictVersions(EdgeState incomingEdge) {
    if (incomingEdge.getFrom().endorsesStrictVersionsFrom == null) {
        return StrictVersionConstraints.EMPTY;
    }
    boolean filterOwn = false;
    StrictVersionConstraints singleStrictVersionConstraints = StrictVersionConstraints.EMPTY;
    Set<ModuleIdentifier> collectedConstraints = null;
    for (EdgeState edgeState : incomingEdge.getFrom().endorsesStrictVersionsFrom) {
        if (edgeState == incomingEdge) {
            // These are my own constraints. I can not treat them as inherited,
            // because that assumes that they are defined in another node as well and might be ignored.
            filterOwn = true;
            continue;
        }
        ComponentState targetComponent = edgeState.getTargetComponent();
        if (targetComponent != null) {
            // may be null if the build is about to fail
            for (NodeState sourceNode : targetComponent.getNodes()) {
                if (sourceNode.ownStrictVersionConstraints == null) {
                    // node's dependencies were not yet visited
                    sourceNode.collectOwnStrictVersions();
                }
                if (singleStrictVersionConstraints.isEmpty()) {
                    singleStrictVersionConstraints = sourceNode.ownStrictVersionConstraints;
                } else {
                    if (collectedConstraints == null) {
                        collectedConstraints = Sets.newHashSet();
                        collectedConstraints.addAll(singleStrictVersionConstraints.getModules());
                    }
                    collectedConstraints.addAll(sourceNode.ownStrictVersionConstraints.getModules());
                }
            }
        }
    }
    if (filterOwn) {
        Set<ModuleIdentifier> resultSet;
        if (collectedConstraints != null) {
            resultSet = collectedConstraints;
        } else {
            resultSet = singleStrictVersionConstraints.getModules();
        }
        if (ownStrictVersionConstraints == null) {
            collectOwnStrictVersions();
        }
        for (ModuleIdentifier ownConstraint : ownStrictVersionConstraints.getModules()) {
            if (resultSet.contains(ownConstraint)) {
                if (collectedConstraints == null) {
                    collectedConstraints = Sets.newHashSet();
                    collectedConstraints.addAll(singleStrictVersionConstraints.getModules());
                }
                collectedConstraints.remove(ownConstraint);
            }
        }
    }
    if (collectedConstraints != null) {
        return StrictVersionConstraints.of(collectedConstraints);
    } else {
        return singleStrictVersionConstraints;
    }
}
Also used : StrictVersionConstraints(org.gradle.api.internal.artifacts.ivyservice.resolveengine.strict.StrictVersionConstraints) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 2 with StrictVersionConstraints

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.strict.StrictVersionConstraints in project gradle by gradle.

the class NodeState method collectAncestorsStrictVersionsSingleEdge.

private void collectAncestorsStrictVersionsSingleEdge(List<EdgeState> incomingEdges) {
    EdgeState dependencyEdge = incomingEdges.get(0);
    StrictVersionConstraints parentStrictVersionConstraints = notNull(dependencyEdge.getFrom().ownStrictVersionConstraints);
    StrictVersionConstraints parentAncestorsStrictVersionConstraints = notNull(dependencyEdge.getFrom().ancestorsStrictVersionConstraints);
    StrictVersionConstraints parentEndorsedStrictVersionConstraints = getEndorsedStrictVersions(dependencyEdge);
    ancestorsStrictVersionConstraints = parentStrictVersionConstraints.union(parentAncestorsStrictVersionConstraints).union(parentEndorsedStrictVersionConstraints);
}
Also used : StrictVersionConstraints(org.gradle.api.internal.artifacts.ivyservice.resolveengine.strict.StrictVersionConstraints)

Example 3 with StrictVersionConstraints

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.strict.StrictVersionConstraints in project gradle by gradle.

the class NodeState method collectAncestorsStrictVersionsMultiEdges.

private void collectAncestorsStrictVersionsMultiEdges(List<EdgeState> incomingEdges) {
    StrictVersionConstraints constraints = null;
    for (EdgeState dependencyEdge : incomingEdges) {
        StrictVersionConstraints parentStrictVersionConstraints = notNull(dependencyEdge.getFrom().ownStrictVersionConstraints);
        StrictVersionConstraints parentAncestorsStrictVersionConstraints = notNull(dependencyEdge.getFrom().ancestorsStrictVersionConstraints);
        StrictVersionConstraints parentEndorsedStrictVersionConstraints = getEndorsedStrictVersions(dependencyEdge);
        if (constraints == null) {
            constraints = parentStrictVersionConstraints.union(parentAncestorsStrictVersionConstraints).union(parentEndorsedStrictVersionConstraints);
        } else {
            constraints = constraints.intersect(parentStrictVersionConstraints.union(parentAncestorsStrictVersionConstraints).union(parentEndorsedStrictVersionConstraints));
        }
        if (constraints == StrictVersionConstraints.EMPTY) {
            ancestorsStrictVersionConstraints = constraints;
            return;
        }
    }
    ancestorsStrictVersionConstraints = constraints;
}
Also used : StrictVersionConstraints(org.gradle.api.internal.artifacts.ivyservice.resolveengine.strict.StrictVersionConstraints)

Aggregations

StrictVersionConstraints (org.gradle.api.internal.artifacts.ivyservice.resolveengine.strict.StrictVersionConstraints)3 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)1