Search in sources :

Example 1 with CapabilitiesMetadata

use of org.gradle.api.capabilities.CapabilitiesMetadata in project gradle by gradle.

the class RealisedIvyModuleResolveMetadata method applyRules.

private static RealisedConfigurationMetadata applyRules(ModuleComponentIdentifier id, String configurationName, VariantMetadataRules variantMetadataRules, ImmutableAttributes attributes, ImmutableCapabilities capabilities, ImmutableList<? extends ModuleComponentArtifactMetadata> artifacts, ImmutableList<ExcludeMetadata> excludes, boolean transitive, boolean visible, ImmutableSet<String> hierarchy, IvyConfigurationHelper configurationHelper, @Nullable List<ModuleDependencyMetadata> dependenciesOverride, boolean addedByRule, boolean isExternalVariant) {
    NameOnlyVariantResolveMetadata variant = new NameOnlyVariantResolveMetadata(configurationName);
    ImmutableAttributes variantAttributes = variantMetadataRules.applyVariantAttributeRules(variant, attributes);
    CapabilitiesMetadata capabilitiesMetadata = variantMetadataRules.applyCapabilitiesRules(variant, capabilities);
    ImmutableList<? extends ModuleComponentArtifactMetadata> artifactsMetadata = variantMetadataRules.applyVariantFilesMetadataRulesToArtifacts(variant, artifacts, id);
    return createConfiguration(id, configurationName, transitive, visible, hierarchy, artifactsMetadata, excludes, variantAttributes, ImmutableCapabilities.of(capabilitiesMetadata.getCapabilities()), variantMetadataRules, configurationHelper, dependenciesOverride, addedByRule, isExternalVariant);
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) CapabilitiesMetadata(org.gradle.api.capabilities.CapabilitiesMetadata)

Example 2 with CapabilitiesMetadata

use of org.gradle.api.capabilities.CapabilitiesMetadata in project gradle by gradle.

the class AttributeConfigurationSelector method filterVariantsByRequestedCapabilities.

private static ImmutableList<ConfigurationMetadata> filterVariantsByRequestedCapabilities(ComponentResolveMetadata targetComponent, Collection<? extends Capability> explicitRequestedCapabilities, Collection<? extends ConfigurationMetadata> consumableConfigurations, String group, String name, boolean lenient, AttributeMatchingExplanationBuilder explanationBuilder) {
    if (consumableConfigurations.isEmpty()) {
        return ImmutableList.of();
    }
    ImmutableList.Builder<ConfigurationMetadata> builder = ImmutableList.builderWithExpectedSize(consumableConfigurations.size());
    boolean explicitlyRequested = !explicitRequestedCapabilities.isEmpty();
    for (ConfigurationMetadata configuration : consumableConfigurations) {
        CapabilitiesMetadata capabilitiesMetadata = configuration.getCapabilities();
        List<? extends Capability> capabilities = capabilitiesMetadata.getCapabilities();
        MatchResult result;
        if (explicitlyRequested) {
            // some capabilities are explicitly required (in other words, we're not _necessarily_ looking for the default capability
            // so we need to filter the configurations
            result = providesAllCapabilities(targetComponent, explicitRequestedCapabilities, capabilities);
        } else {
            // we need to make sure the variants we consider provide the implicit capability
            result = containsImplicitCapability(capabilitiesMetadata, capabilities, group, name);
        }
        if (result.matches) {
            if (lenient || result == MatchResult.EXACT_MATCH) {
                builder.add(configuration);
            }
        }
    }
    return builder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) CapabilitiesMetadata(org.gradle.api.capabilities.CapabilitiesMetadata)

Example 3 with CapabilitiesMetadata

use of org.gradle.api.capabilities.CapabilitiesMetadata in project gradle by gradle.

the class RealisedMavenModuleResolveMetadata method applyRules.

private static RealisedConfigurationMetadata applyRules(ModuleComponentIdentifier id, String configurationName, VariantMetadataRules variantMetadataRules, ImmutableAttributes attributes, ImmutableCapabilities capabilities, List<? extends ModuleDependencyMetadata> dependencies, ImmutableList<? extends ModuleComponentArtifactMetadata> artifacts, boolean transitive, boolean visible, ImmutableSet<String> hierarchy, boolean addedByRule, boolean isExternalVariant) {
    NameOnlyVariantResolveMetadata variant = new NameOnlyVariantResolveMetadata(configurationName);
    ImmutableAttributes variantAttributes = variantMetadataRules.applyVariantAttributeRules(variant, attributes);
    CapabilitiesMetadata capabilitiesMetadata = variantMetadataRules.applyCapabilitiesRules(variant, capabilities);
    List<? extends DependencyMetadata> dependenciesMetadata = variantMetadataRules.applyDependencyMetadataRules(variant, dependencies);
    ImmutableList<? extends ModuleComponentArtifactMetadata> artifactsMetadata = variantMetadataRules.applyVariantFilesMetadataRulesToArtifacts(variant, artifacts, id);
    return createConfiguration(id, configurationName, transitive, visible, hierarchy, artifactsMetadata, dependenciesMetadata, variantAttributes, ImmutableCapabilities.of(capabilitiesMetadata.getCapabilities()), addedByRule, isExternalVariant);
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) CapabilitiesMetadata(org.gradle.api.capabilities.CapabilitiesMetadata)

Example 4 with CapabilitiesMetadata

use of org.gradle.api.capabilities.CapabilitiesMetadata in project gradle by gradle.

the class LazyToRealisedModuleComponentResolveMetadataHelper method applyRules.

private static AbstractRealisedModuleComponentResolveMetadata.ImmutableRealisedVariantImpl applyRules(ComponentVariant variant, VariantMetadataRules variantMetadataRules, ModuleComponentIdentifier id) {
    ImmutableAttributes attributes = variantMetadataRules.applyVariantAttributeRules(variant, variant.getAttributes());
    CapabilitiesMetadata capabilitiesMetadata = variantMetadataRules.applyCapabilitiesRules(variant, variant.getCapabilities());
    ImmutableList<? extends ComponentVariant.File> files = variantMetadataRules.applyVariantFilesMetadataRulesToFiles(variant, variant.getFiles(), id);
    boolean force = PlatformSupport.hasForcedDependencies(variant);
    List<GradleDependencyMetadata> dependencies = variantMetadataRules.applyDependencyMetadataRules(variant, convertDependencies(variant.getDependencies(), variant.getDependencyConstraints(), force));
    return new AbstractRealisedModuleComponentResolveMetadata.ImmutableRealisedVariantImpl(id, variant.getName(), attributes, variant.getDependencies(), variant.getDependencyConstraints(), files, ImmutableCapabilities.of(capabilitiesMetadata.getCapabilities()), dependencies, variant.isExternalVariant());
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) CapabilitiesMetadata(org.gradle.api.capabilities.CapabilitiesMetadata)

Aggregations

CapabilitiesMetadata (org.gradle.api.capabilities.CapabilitiesMetadata)4 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)3 ImmutableList (com.google.common.collect.ImmutableList)1