use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class EdgeState method calculateTargetConfigurations.
private void calculateTargetConfigurations() {
targetNodes.clear();
targetNodeSelectionFailure = null;
ComponentResolveMetadata targetModuleVersion = targetModuleRevision.getMetadata();
if (targetModuleVersion == null) {
// Broken version
return;
}
ImmutableAttributes attributes = resolveState.getRoot().getMetadata().getAttributes();
List<ConfigurationMetadata> targetConfigurations;
try {
targetConfigurations = dependencyMetadata.selectConfigurations(attributes, targetModuleVersion, resolveState.getAttributesSchema());
} catch (Throwable 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(targetModuleRevision, targetConfiguration);
this.targetNodes.add(targetNodeState);
}
}
use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class IvyDependencyDescriptor method findMatches.
private void findMatches(ComponentIdentifier fromComponent, ComponentResolveMetadata targetComponent, String fromConfiguration, String patternConfiguration, String targetPattern, List<ConfigurationMetadata> targetConfigurations) {
int startFallback = targetPattern.indexOf('(');
if (startFallback >= 0) {
if (targetPattern.endsWith(")")) {
String preferred = targetPattern.substring(0, startFallback);
ConfigurationMetadata configuration = targetComponent.getConfiguration(preferred);
if (configuration != null) {
maybeAddConfiguration(targetConfigurations, configuration);
return;
}
targetPattern = targetPattern.substring(startFallback + 1, targetPattern.length() - 1);
}
}
if (targetPattern.equals("*")) {
for (String targetName : targetComponent.getConfigurationNames()) {
ConfigurationMetadata configuration = targetComponent.getConfiguration(targetName);
if (configuration.isVisible()) {
maybeAddConfiguration(targetConfigurations, configuration);
}
}
return;
}
if (targetPattern.equals("@")) {
targetPattern = patternConfiguration;
} else if (targetPattern.equals("#")) {
targetPattern = fromConfiguration;
}
ConfigurationMetadata configuration = targetComponent.getConfiguration(targetPattern);
if (configuration == null) {
throw new ConfigurationNotFoundException(fromComponent, fromConfiguration, targetPattern, targetComponent.getId());
}
maybeAddConfiguration(targetConfigurations, configuration);
}
use of org.gradle.internal.component.model.ConfigurationMetadata 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.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class AbstractLazyModuleComponentResolveMetadata method getConfiguration.
@Override
public synchronized ConfigurationMetadata getConfiguration(final String name) {
ConfigurationMetadata populated = configurations.get(name);
if (populated != null) {
return populated;
}
ConfigurationMetadata md = populateConfigurationFromDescriptor(name, configurationDefinitions);
configurations.put(name, md);
return md;
}
use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class AbstractRealisedModuleResolveMetadataSerializationHelper method writeRealisedConfigurationsData.
public void writeRealisedConfigurationsData(Encoder encoder, AbstractRealisedModuleComponentResolveMetadata transformed, Map<ExternalDependencyDescriptor, Integer> deduplicationDependencyCache) throws IOException {
encoder.writeSmallInt(transformed.getConfigurationNames().size());
for (String configurationName : transformed.getConfigurationNames()) {
ConfigurationMetadata configuration = transformed.getConfiguration(configurationName);
writeConfiguration(encoder, configuration);
writeFiles(encoder, configuration.getArtifacts());
writeDependencies(encoder, configuration, deduplicationDependencyCache);
}
}
Aggregations