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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations