use of org.gradle.internal.component.external.model.VariantMetadataRules 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);
}
use of org.gradle.internal.component.external.model.VariantMetadataRules 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);
}
Aggregations