use of org.gradle.internal.component.external.model.ImmutableCapabilities 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.ImmutableCapabilities 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.ImmutableCapabilities 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.ImmutableCapabilities in project gradle by gradle.
the class DefaultLocalComponentMetadataBuilder method createConfiguration.
private BuildableLocalConfigurationMetadata createConfiguration(BuildableLocalComponentMetadata metaData, ConfigurationInternal configuration) {
configuration.preventFromFurtherMutation();
ImmutableSet<String> hierarchy = Configurations.getNames(configuration.getHierarchy());
ImmutableSet<String> extendsFrom = Configurations.getNames(configuration.getExtendsFrom());
// Presence of capabilities is bound to the definition of a capabilities extension to the project
ImmutableCapabilities capabilities = ImmutableCapabilities.copyAsImmutable(Configurations.collectCapabilities(configuration, Sets.newHashSet(), Sets.newHashSet()));
return metaData.addConfiguration(configuration.getName(), configuration.getDescription(), extendsFrom, hierarchy, configuration.isVisible(), configuration.isTransitive(), configuration.getAttributes().asImmutable(), configuration.isCanBeConsumed(), configuration.getConsumptionDeprecation(), configuration.isCanBeResolved(), capabilities, configuration.getConsistentResolutionConstraints());
}
use of org.gradle.internal.component.external.model.ImmutableCapabilities in project gradle by gradle.
the class RealisedIvyModuleResolveMetadata method addVariantsFromRules.
private static void addVariantsFromRules(DefaultIvyModuleResolveMetadata componentMetadata, Map<String, ConfigurationMetadata> declaredConfigurations, VariantMetadataRules variantMetadataRules) {
List<AdditionalVariant> additionalVariants = variantMetadataRules.getAdditionalVariants();
if (additionalVariants.isEmpty()) {
return;
}
for (AdditionalVariant additionalVariant : additionalVariants) {
String name = additionalVariant.getName();
String baseName = additionalVariant.getBase();
ImmutableAttributes attributes;
ImmutableCapabilities capabilities;
List<ModuleDependencyMetadata> dependencies;
ImmutableList<? extends ModuleComponentArtifactMetadata> artifacts;
ImmutableList<ExcludeMetadata> excludes;
ModuleConfigurationMetadata baseConf = (ModuleConfigurationMetadata) declaredConfigurations.get(baseName);
if (baseConf == null) {
attributes = componentMetadata.getAttributes();
capabilities = ImmutableCapabilities.EMPTY;
dependencies = ImmutableList.of();
artifacts = ImmutableList.of();
excludes = ImmutableList.of();
} else {
attributes = baseConf.getAttributes();
capabilities = (ImmutableCapabilities) baseConf.getCapabilities();
dependencies = Cast.uncheckedCast(baseConf.getDependencies());
artifacts = Cast.uncheckedCast(baseConf.getArtifacts());
excludes = Cast.uncheckedCast(baseConf.getExcludes());
}
if (baseName == null || baseConf != null) {
declaredConfigurations.put(name, applyRules(componentMetadata.getId(), name, variantMetadataRules, attributes, capabilities, artifacts, excludes, true, true, ImmutableSet.of(), null, dependencies, true, false));
} else if (!additionalVariant.isLenient()) {
throw new InvalidUserDataException("Configuration '" + baseName + "' not defined in module " + componentMetadata.getId().getDisplayName());
}
}
}
Aggregations