use of org.gradle.api.internal.attributes.AttributeMergingException in project gradle by gradle.
the class EdgeState method calculateTargetConfigurations.
private void calculateTargetConfigurations(ComponentState targetComponent) {
ComponentResolveMetadata targetModuleVersion = targetComponent.getMetadata();
targetNodes.clear();
targetNodeSelectionFailure = null;
if (targetModuleVersion == null) {
targetComponent.getModule().getPlatformState().addOrphanEdge(this);
// Broken version
return;
}
if (isConstraint && !isVirtualDependency()) {
List<NodeState> nodes = targetComponent.getNodes();
for (NodeState node : nodes) {
if (node.isSelected()) {
targetNodes.add(node);
}
}
if (targetNodes.isEmpty()) {
// There is a chance we could not attach target configurations previously
List<EdgeState> unattachedDependencies = targetComponent.getModule().getUnattachedDependencies();
if (!unattachedDependencies.isEmpty()) {
for (EdgeState otherEdge : unattachedDependencies) {
if (otherEdge != this && !otherEdge.isConstraint()) {
otherEdge.attachToTargetConfigurations();
if (otherEdge.targetNodeSelectionFailure != null) {
// Copy selection failure
this.targetNodeSelectionFailure = otherEdge.targetNodeSelectionFailure;
return;
}
break;
}
}
}
for (NodeState node : nodes) {
if (node.isSelected()) {
targetNodes.add(node);
}
}
}
return;
}
List<ConfigurationMetadata> targetConfigurations;
try {
ImmutableAttributes attributes = resolveState.getRoot().getMetadata().getAttributes();
attributes = resolveState.getAttributesFactory().concat(attributes, safeGetAttributes());
targetConfigurations = dependencyMetadata.selectConfigurations(attributes, targetModuleVersion, resolveState.getAttributesSchema(), dependencyState.getDependency().getSelector().getRequestedCapabilities());
} catch (AttributeMergingException mergeError) {
targetNodeSelectionFailure = new ModuleVersionResolveException(dependencyState.getRequested(), () -> {
Attribute<?> attribute = mergeError.getAttribute();
Object constraintValue = mergeError.getLeftValue();
Object dependencyValue = mergeError.getRightValue();
return "Inconsistency between attributes of a constraint and a dependency, on attribute '" + attribute + "' : dependency requires '" + dependencyValue + "' while constraint required '" + constraintValue + "'";
});
return;
} catch (Exception t) {
// Failure to select the target variant/configurations from this component, given the dependency attributes/metadata.
targetNodeSelectionFailure = new ModuleVersionResolveException(dependencyState.getRequested(), t);
return;
}
for (ConfigurationMetadata targetConfiguration : targetConfigurations) {
NodeState targetNodeState = resolveState.getNode(targetComponent, targetConfiguration);
this.targetNodes.add(targetNodeState);
}
}
use of org.gradle.api.internal.attributes.AttributeMergingException in project gradle by gradle.
the class ModuleResolveState method appendAttributes.
private ImmutableAttributes appendAttributes(ImmutableAttributes dependencyAttributes, SelectorState selectorState) {
try {
DependencyMetadata dependencyMetadata = selectorState.getDependencyMetadata();
boolean constraint = dependencyMetadata.isConstraint();
if (constraint) {
ComponentSelector selector = dependencyMetadata.getSelector();
ImmutableAttributes attributes = ((AttributeContainerInternal) selector.getAttributes()).asImmutable();
dependencyAttributes = attributesFactory.safeConcat(attributes, dependencyAttributes);
}
} catch (AttributeMergingException e) {
attributeMergingError = e;
}
return dependencyAttributes;
}
Aggregations