use of org.gradle.api.attributes.Attribute in project gradle by gradle.
the class DependencyGraphBuilder method assertCompatibleAttributes.
private void assertCompatibleAttributes(NodeState first, NodeState second, Set<NodeState> incompatibleNodes) {
ImmutableAttributes firstAttributes = first.getMetadata().getAttributes();
ImmutableAttributes secondAttributes = second.getMetadata().getAttributes();
ImmutableSet<Attribute<?>> firstKeys = firstAttributes.keySet();
ImmutableSet<Attribute<?>> secondKeys = secondAttributes.keySet();
for (Attribute<?> attribute : Sets.intersection(firstKeys, secondKeys)) {
CompatibilityRule<Object> rule = attributesSchema.compatibilityRules(attribute);
Object v1 = firstAttributes.getAttribute(attribute);
Object v2 = secondAttributes.getAttribute(attribute);
// for all commons attributes, make sure they are compatible with each other
if (!compatible(rule, v1, v2) && !compatible(rule, v2, v1)) {
incompatibleNodes.add(first);
incompatibleNodes.add(second);
}
}
}
use of org.gradle.api.attributes.Attribute in project gradle by gradle.
the class AttributeSelectionUtils method collectExtraAttributes.
public static Attribute<?>[] collectExtraAttributes(AttributeSelectionSchema schema, ImmutableAttributes[] candidateAttributeSets, ImmutableAttributes requested) {
Set<Attribute<?>> extraAttributes = Sets.newLinkedHashSet();
for (ImmutableAttributes attributes : candidateAttributeSets) {
extraAttributes.addAll(attributes.keySet());
}
removeSameAttributes(requested, extraAttributes);
Attribute<?>[] extraAttributesArray = extraAttributes.toArray(new Attribute<?>[0]);
for (int i = 0; i < extraAttributesArray.length; i++) {
Attribute<?> extraAttribute = extraAttributesArray[i];
Attribute<?> schemaAttribute = schema.getAttribute(extraAttribute.getName());
if (schemaAttribute != null) {
extraAttributesArray[i] = schemaAttribute;
}
}
return extraAttributesArray;
}
Aggregations