Search in sources :

Example 26 with ConfigurationMetadata

use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.

the class NoMatchingCapabilitiesException method buildMessage.

private static String buildMessage(ComponentResolveMetadata targetComponent, Collection<? extends Capability> requestedCapabilities, ImmutableList<? extends ConfigurationMetadata> candidates) {
    StringBuilder sb = new StringBuilder("Unable to find a variant of ");
    sb.append(targetComponent.getId()).append(" providing the requested ");
    sb.append(CapabilitiesSupport.prettifyCapabilities(targetComponent, requestedCapabilities));
    sb.append(":\n");
    for (ConfigurationMetadata candidate : candidates) {
        sb.append("   - Variant ").append(candidate.getName()).append(" provides ");
        sb.append(CapabilitiesSupport.sortedCapabilityList(targetComponent, candidate.getCapabilities().getCapabilities())).append("\n");
    }
    return sb.toString();
}
Also used : ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata)

Example 27 with ConfigurationMetadata

use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.

the class RealisedIvyModuleResolveMetadata method transform.

public static RealisedIvyModuleResolveMetadata transform(DefaultIvyModuleResolveMetadata metadata) {
    VariantMetadataRules variantMetadataRules = metadata.getVariantMetadataRules();
    ImmutableList<ImmutableRealisedVariantImpl> variants = LazyToRealisedModuleComponentResolveMetadataHelper.realiseVariants(metadata, variantMetadataRules, metadata.getVariants());
    Map<String, ConfigurationMetadata> configurations = realiseConfigurations(metadata, variantMetadataRules);
    if (variants.isEmpty()) {
        addVariantsFromRules(metadata, configurations, variantMetadataRules);
    }
    return new RealisedIvyModuleResolveMetadata(metadata, variants, configurations);
}
Also used : VariantMetadataRules(org.gradle.internal.component.external.model.VariantMetadataRules) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) ModuleConfigurationMetadata(org.gradle.internal.component.model.ModuleConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata)

Example 28 with ConfigurationMetadata

use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.

the class RealisedIvyModuleResolveMetadata method withDependencies.

private IvyModuleResolveMetadata withDependencies(Map<IvyDependencyDescriptor, IvyDependencyDescriptor> transformed) {
    ImmutableList<IvyDependencyDescriptor> transformedDescriptors = ImmutableList.copyOf(transformed.values());
    Set<String> configurationNames = getConfigurationNames();
    Map<String, ConfigurationMetadata> transformedConfigurations = Maps.newHashMapWithExpectedSize(configurationNames.size());
    for (String name : configurationNames) {
        RealisedConfigurationMetadata configuration = (RealisedConfigurationMetadata) getConfiguration(name);
        List<? extends DependencyMetadata> dependencies = configuration.getDependencies();
        ImmutableList.Builder<ModuleDependencyMetadata> transformedConfigurationDependencies = ImmutableList.builder();
        for (DependencyMetadata dependency : dependencies) {
            if (dependency instanceof ConfigurationBoundExternalDependencyMetadata) {
                transformedConfigurationDependencies.add(((ConfigurationBoundExternalDependencyMetadata) dependency).withDescriptor(transformed.get(((ConfigurationBoundExternalDependencyMetadata) dependency).getDependencyDescriptor())));
            } else {
                transformedConfigurationDependencies.add((ModuleDependencyMetadata) dependency);
            }
        }
        transformedConfigurations.put(name, configuration.withDependencies(transformedConfigurationDependencies.build()));
    }
    return new RealisedIvyModuleResolveMetadata(this, transformedDescriptors, transformedConfigurations);
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) ModuleConfigurationMetadata(org.gradle.internal.component.model.ModuleConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata) DependencyMetadata(org.gradle.internal.component.model.DependencyMetadata) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata)

Example 29 with ConfigurationMetadata

use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.

the class RealisedMavenModuleResolveMetadataSerializationHelper method readMetadata.

public ModuleComponentResolveMetadata readMetadata(Decoder decoder, DefaultMavenModuleResolveMetadata resolveMetadata, Map<Integer, MavenDependencyDescriptor> deduplicationDependencyCache) throws IOException {
    Map<String, List<GradleDependencyMetadata>> variantToDependencies = readVariantDependencies(decoder);
    ImmutableList<? extends ComponentVariant> variants = resolveMetadata.getVariants();
    ImmutableList.Builder<AbstractRealisedModuleComponentResolveMetadata.ImmutableRealisedVariantImpl> builder = ImmutableList.builder();
    for (ComponentVariant variant : variants) {
        builder.add(new AbstractRealisedModuleComponentResolveMetadata.ImmutableRealisedVariantImpl(resolveMetadata.getId(), variant.getName(), variant.getAttributes().asImmutable(), variant.getDependencies(), variant.getDependencyConstraints(), variant.getFiles(), ImmutableCapabilities.of(variant.getCapabilities().getCapabilities()), variantToDependencies.get(variant.getName()), variant.isExternalVariant()));
    }
    ImmutableList<AbstractRealisedModuleComponentResolveMetadata.ImmutableRealisedVariantImpl> realisedVariants = builder.build();
    Map<String, ConfigurationMetadata> configurations = readMavenConfigurations(decoder, resolveMetadata, deduplicationDependencyCache);
    ImmutableList<ConfigurationMetadata> derivedVariants = readDerivedVariants(decoder, resolveMetadata, deduplicationDependencyCache);
    return new RealisedMavenModuleResolveMetadata(resolveMetadata, realisedVariants, derivedVariants, configurations);
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) AbstractRealisedModuleComponentResolveMetadata(org.gradle.internal.component.external.model.AbstractRealisedModuleComponentResolveMetadata) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata) ComponentVariant(org.gradle.internal.component.external.model.ComponentVariant) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List)

Example 30 with ConfigurationMetadata

use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.

the class RealisedMavenModuleResolveMetadata method transform.

/**
 * Factory method to transform a {@link DefaultMavenModuleResolveMetadata}, which is lazy, in a realised version.
 *
 * @param metadata the lazy metadata to transform
 * @return the realised version of the metadata
 */
public static RealisedMavenModuleResolveMetadata transform(DefaultMavenModuleResolveMetadata metadata) {
    VariantMetadataRules variantMetadataRules = metadata.getVariantMetadataRules();
    ImmutableList<? extends ComponentVariant> variants = LazyToRealisedModuleComponentResolveMetadataHelper.realiseVariants(metadata, variantMetadataRules, metadata.getVariants());
    Map<String, ConfigurationMetadata> configurations = Maps.newHashMapWithExpectedSize(metadata.getConfigurationNames().size());
    List<ConfigurationMetadata> derivedVariants = ImmutableList.of();
    if (variants.isEmpty()) {
        Optional<ImmutableList<? extends ConfigurationMetadata>> maybeDeriveVariants = metadata.maybeDeriveVariants();
        if (maybeDeriveVariants.isPresent()) {
            ImmutableList.Builder<ConfigurationMetadata> builder = new ImmutableList.Builder<>();
            for (ConfigurationMetadata derivedVariant : maybeDeriveVariants.get()) {
                ImmutableList<ModuleDependencyMetadata> dependencies = Cast.uncheckedCast(derivedVariant.getDependencies());
                // We do not need to apply the rules manually to derived variants, because the derivation already
                // instantiated 'derivedVariant' as 'DefaultConfigurationMetadata' which does the rules application
                // automatically when calling the getters (done in the code below).
                RealisedConfigurationMetadata derivedVariantMetadata = new RealisedConfigurationMetadata(metadata.getId(), derivedVariant.getName(), derivedVariant.isTransitive(), derivedVariant.isVisible(), derivedVariant.getHierarchy(), Cast.uncheckedCast(derivedVariant.getArtifacts()), derivedVariant.getExcludes(), derivedVariant.getAttributes(), (ImmutableCapabilities) derivedVariant.getCapabilities(), dependencies, false, derivedVariant.isExternalVariant());
                builder.add(derivedVariantMetadata);
            }
            derivedVariants = addVariantsFromRules(metadata, builder.build(), variantMetadataRules);
        }
    }
    for (String configurationName : metadata.getConfigurationNames()) {
        configurations.put(configurationName, createConfiguration(metadata, configurationName));
    }
    return new RealisedMavenModuleResolveMetadata(metadata, variants, derivedVariants, configurations);
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) ModuleConfigurationMetadata(org.gradle.internal.component.model.ModuleConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata) VariantMetadataRules(org.gradle.internal.component.external.model.VariantMetadataRules)

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