Search in sources :

Example 21 with ConfigurationMetadata

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);
    }
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) ComponentResolveMetadata(org.gradle.internal.component.model.ComponentResolveMetadata) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata)

Example 22 with ConfigurationMetadata

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);
}
Also used : ConfigurationNotFoundException(org.gradle.internal.component.model.ConfigurationNotFoundException) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata)

Example 23 with ConfigurationMetadata

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);
    }
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) ComponentResolveMetadata(org.gradle.internal.component.model.ComponentResolveMetadata) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) AttributeMergingException(org.gradle.api.internal.attributes.AttributeMergingException) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) AttributeMergingException(org.gradle.api.internal.attributes.AttributeMergingException)

Example 24 with ConfigurationMetadata

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;
}
Also used : ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) ModuleConfigurationMetadata(org.gradle.internal.component.model.ModuleConfigurationMetadata)

Example 25 with ConfigurationMetadata

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);
    }
}
Also used : ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata)

Aggregations

ConfigurationMetadata (org.gradle.internal.component.model.ConfigurationMetadata)32 ImmutableList (com.google.common.collect.ImmutableList)10 RealisedConfigurationMetadata (org.gradle.internal.component.external.model.RealisedConfigurationMetadata)8 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)6 ModuleConfigurationMetadata (org.gradle.internal.component.model.ModuleConfigurationMetadata)6 TreeMap (java.util.TreeMap)4 ModuleDependencyMetadata (org.gradle.internal.component.external.model.ModuleDependencyMetadata)4 ImmutableCapabilities (org.gradle.internal.component.external.model.ImmutableCapabilities)3 ComponentResolveMetadata (org.gradle.internal.component.model.ComponentResolveMetadata)3 ConfigurationNotFoundException (org.gradle.internal.component.model.ConfigurationNotFoundException)3 TreeFormatter (org.gradle.internal.text.TreeFormatter)3 InvalidUserDataException (org.gradle.api.InvalidUserDataException)2 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)2 Configuration (org.gradle.internal.component.external.descriptor.Configuration)2 VariantMetadataRules (org.gradle.internal.component.external.model.VariantMetadataRules)2 LocalConfigurationMetadata (org.gradle.internal.component.local.model.LocalConfigurationMetadata)2 TreeFormatter (org.gradle.internal.logging.text.TreeFormatter)2 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1