Search in sources :

Example 1 with RealisedConfigurationMetadata

use of org.gradle.internal.component.external.model.RealisedConfigurationMetadata in project gradle by gradle.

the class RealisedIvyModuleResolveMetadataSerializationHelper method readIvyConfigurations.

private Map<String, ConfigurationMetadata> readIvyConfigurations(Decoder decoder, DefaultIvyModuleResolveMetadata metadata) throws IOException {
    IvyConfigurationHelper configurationHelper = new IvyConfigurationHelper(metadata.getArtifactDefinitions(), new IdentityHashMap<>(), metadata.getExcludes(), metadata.getDependencies(), metadata.getId());
    ImmutableMap<String, Configuration> configurationDefinitions = metadata.getConfigurationDefinitions();
    int configurationsCount = decoder.readSmallInt();
    Map<String, ConfigurationMetadata> configurations = Maps.newHashMapWithExpectedSize(configurationsCount);
    for (int i = 0; i < configurationsCount; i++) {
        String configurationName = decoder.readString();
        boolean transitive = true;
        boolean visible = true;
        ImmutableSet<String> hierarchy = ImmutableSet.of(configurationName);
        ImmutableList<ExcludeMetadata> excludes;
        Configuration configuration = configurationDefinitions.get(configurationName);
        if (configuration != null) {
            // if the configuration represents a variant added by a rule, it is not in the definition list
            transitive = configuration.isTransitive();
            visible = configuration.isVisible();
            hierarchy = LazyToRealisedModuleComponentResolveMetadataHelper.constructHierarchy(configuration, configurationDefinitions);
            excludes = configurationHelper.filterExcludes(hierarchy);
        } else {
            excludes = ImmutableList.of();
        }
        ImmutableAttributes attributes = getAttributeContainerSerializer().read(decoder);
        ImmutableCapabilities capabilities = readCapabilities(decoder);
        boolean isExternalVariant = decoder.readBoolean();
        boolean hasExplicitExcludes = decoder.readBoolean();
        if (hasExplicitExcludes) {
            excludes = ImmutableList.copyOf(readMavenExcludes(decoder));
        }
        ImmutableList<? extends ModuleComponentArtifactMetadata> artifacts = readFiles(decoder, metadata.getId());
        RealisedConfigurationMetadata configurationMetadata = new RealisedConfigurationMetadata(metadata.getId(), configurationName, transitive, visible, hierarchy, artifacts, excludes, attributes, capabilities, false, isExternalVariant);
        ImmutableList.Builder<ModuleDependencyMetadata> builder = ImmutableList.builder();
        int dependenciesCount = decoder.readSmallInt();
        for (int j = 0; j < dependenciesCount; j++) {
            byte dependencyType = decoder.readByte();
            switch(dependencyType) {
                case GRADLE_DEPENDENCY_METADATA:
                    builder.add(readDependencyMetadata(decoder));
                    break;
                case IVY_DEPENDENCY_METADATA:
                    IvyDependencyDescriptor ivyDependency = readIvyDependency(decoder);
                    ModuleDependencyMetadata dependencyMetadata = configurationHelper.contextualize(configurationMetadata, metadata.getId(), ivyDependency);
                    builder.add(dependencyMetadata.withReason(decoder.readNullableString()));
                    break;
                case MAVEN_DEPENDENCY_METADATA:
                    throw new IllegalStateException("Unexpected Maven dependency for Ivy module");
                default:
                    throw new IllegalStateException("Unknown dependency type " + dependencyType);
            }
        }
        ImmutableList<ModuleDependencyMetadata> dependencies = builder.build();
        configurationMetadata.setDependencies(dependencies);
        configurations.put(configurationName, configurationMetadata);
    }
    return configurations;
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) Configuration(org.gradle.internal.component.external.descriptor.Configuration) ImmutableCapabilities(org.gradle.internal.component.external.model.ImmutableCapabilities) ImmutableList(com.google.common.collect.ImmutableList) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 2 with RealisedConfigurationMetadata

use of org.gradle.internal.component.external.model.RealisedConfigurationMetadata in project gradle by gradle.

the class RealisedIvyModuleResolveMetadata method createConfiguration.

private static RealisedConfigurationMetadata createConfiguration(ModuleComponentIdentifier componentId, String name, boolean transitive, boolean visible, ImmutableSet<String> hierarchy, ImmutableList<? extends ModuleComponentArtifactMetadata> artifacts, ImmutableList<ExcludeMetadata> excludes, ImmutableAttributes componentLevelAttributes, ImmutableCapabilities capabilities, VariantMetadataRules variantMetadataRules, IvyConfigurationHelper configurationHelper, List<ModuleDependencyMetadata> dependenciesFromRule, boolean addedByRule, boolean externalVariant) {
    RealisedConfigurationMetadata configuration = new RealisedConfigurationMetadata(componentId, name, transitive, visible, hierarchy, artifacts, excludes, componentLevelAttributes, capabilities, addedByRule, externalVariant);
    List<ModuleDependencyMetadata> dependencyMetadata;
    if (configurationHelper != null) {
        dependencyMetadata = configurationHelper.filterDependencies(configuration);
    } else {
        dependencyMetadata = dependenciesFromRule;
    }
    configuration.setDependencies(ImmutableList.copyOf(variantMetadataRules.applyDependencyMetadataRules(new NameOnlyVariantResolveMetadata(name), dependencyMetadata)));
    return configuration;
}
Also used : ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata)

Example 3 with RealisedConfigurationMetadata

use of org.gradle.internal.component.external.model.RealisedConfigurationMetadata in project gradle by gradle.

the class RealisedMavenModuleResolveMetadataSerializationHelper method readDerivedVariant.

private ConfigurationMetadata readDerivedVariant(Decoder decoder, DefaultMavenModuleResolveMetadata resolveMetadata, Map<Integer, MavenDependencyDescriptor> deduplicationDependencyCache) throws IOException {
    String name = decoder.readString();
    ImmutableAttributes attributes = attributeContainerSerializer.read(decoder);
    ImmutableCapabilities immutableCapabilities = readCapabilities(decoder);
    boolean isExternalVariant = decoder.readBoolean();
    ImmutableList<? extends ModuleComponentArtifactMetadata> artifacts = readFiles(decoder, resolveMetadata.getId());
    boolean transitive = decoder.readBoolean();
    boolean visible = decoder.readBoolean();
    ImmutableSet<String> hierarchy = ImmutableSet.copyOf(readStringSet(decoder));
    List<ExcludeMetadata> excludeMetadata = readMavenExcludes(decoder);
    RealisedConfigurationMetadata realized = new RealisedConfigurationMetadata(resolveMetadata.getId(), name, transitive, visible, hierarchy, artifacts, ImmutableList.copyOf(excludeMetadata), attributes, immutableCapabilities, false, isExternalVariant);
    ImmutableList<ModuleDependencyMetadata> dependencies = readDependencies(decoder, resolveMetadata, realized, deduplicationDependencyCache);
    realized.setDependencies(dependencies);
    return realized;
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) ImmutableCapabilities(org.gradle.internal.component.external.model.ImmutableCapabilities) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata)

Example 4 with RealisedConfigurationMetadata

use of org.gradle.internal.component.external.model.RealisedConfigurationMetadata in project gradle by gradle.

the class RealisedMavenModuleResolveMetadataSerializationHelper method readMavenConfigurations.

private Map<String, ConfigurationMetadata> readMavenConfigurations(Decoder decoder, DefaultMavenModuleResolveMetadata metadata, Map<Integer, MavenDependencyDescriptor> deduplicationDependencyCache) throws IOException {
    ImmutableMap<String, Configuration> configurationDefinitions = metadata.getConfigurationDefinitions();
    int configurationsCount = decoder.readSmallInt();
    Map<String, ConfigurationMetadata> configurations = Maps.newHashMapWithExpectedSize(configurationsCount);
    for (int i = 0; i < configurationsCount; i++) {
        String configurationName = decoder.readString();
        Configuration configuration = configurationDefinitions.get(configurationName);
        ImmutableSet<String> hierarchy = LazyToRealisedModuleComponentResolveMetadataHelper.constructHierarchy(configuration, configurationDefinitions);
        ImmutableAttributes attributes = getAttributeContainerSerializer().read(decoder);
        ImmutableCapabilities capabilities = readCapabilities(decoder);
        boolean isExternalVariant = decoder.readBoolean();
        ImmutableList<? extends ModuleComponentArtifactMetadata> artifacts = readFiles(decoder, metadata.getId());
        RealisedConfigurationMetadata configurationMetadata = new RealisedConfigurationMetadata(metadata.getId(), configurationName, configuration.isTransitive(), configuration.isVisible(), hierarchy, artifacts, ImmutableList.of(), attributes, capabilities, false, isExternalVariant);
        ImmutableList<ModuleDependencyMetadata> dependencies = readDependencies(decoder, metadata, configurationMetadata, deduplicationDependencyCache);
        configurationMetadata.setDependencies(dependencies);
        configurations.put(configurationName, configurationMetadata);
    }
    return configurations;
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) Configuration(org.gradle.internal.component.external.descriptor.Configuration) ImmutableCapabilities(org.gradle.internal.component.external.model.ImmutableCapabilities) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata)

Example 5 with RealisedConfigurationMetadata

use of org.gradle.internal.component.external.model.RealisedConfigurationMetadata 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)

Aggregations

RealisedConfigurationMetadata (org.gradle.internal.component.external.model.RealisedConfigurationMetadata)8 ModuleDependencyMetadata (org.gradle.internal.component.external.model.ModuleDependencyMetadata)7 ConfigurationMetadata (org.gradle.internal.component.model.ConfigurationMetadata)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)3 ImmutableCapabilities (org.gradle.internal.component.external.model.ImmutableCapabilities)3 Configuration (org.gradle.internal.component.external.descriptor.Configuration)2 ConfigurationBoundExternalDependencyMetadata (org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata)2 DependencyMetadata (org.gradle.internal.component.model.DependencyMetadata)2 ExcludeMetadata (org.gradle.internal.component.model.ExcludeMetadata)2 ModuleConfigurationMetadata (org.gradle.internal.component.model.ModuleConfigurationMetadata)2 ExternalDependencyDescriptor (org.gradle.internal.component.external.model.ExternalDependencyDescriptor)1 GradleDependencyMetadata (org.gradle.internal.component.external.model.GradleDependencyMetadata)1 VariantMetadataRules (org.gradle.internal.component.external.model.VariantMetadataRules)1