use of org.gradle.api.publish.internal.versionmapping.DefaultVariantVersionMappingStrategy in project gradle by gradle.
the class DefaultVersionMappingStrategy method findStrategyForVariant.
@Override
public VariantVersionMappingStrategyInternal findStrategyForVariant(ImmutableAttributes variantAttributes) {
DefaultVariantVersionMappingStrategy strategy = createDefaultMappingStrategy(variantAttributes);
// Apply strategies for "all variants"
for (Action<? super VariantVersionMappingStrategy> action : mappingsForAllVariants) {
action.execute(strategy);
}
// Then use attribute specific mapping
if (!attributeBasedMappings.isEmpty()) {
AttributeMatcher matcher = schema.matcher();
Set<ImmutableAttributes> candidates = attributeBasedMappings.keySet();
List<ImmutableAttributes> matches = matcher.matches(candidates, variantAttributes, AttributeMatchingExplanationBuilder.NO_OP);
if (matches.size() == 1) {
Collection<Action<? super VariantVersionMappingStrategy>> actions = attributeBasedMappings.get(matches.get(0));
for (Action<? super VariantVersionMappingStrategy> action : actions) {
action.execute(strategy);
}
} else if (matches.size() > 1) {
throw new InvalidUserCodeException("Unable to find a suitable version mapping strategy for " + variantAttributes);
}
}
return strategy;
}
use of org.gradle.api.publish.internal.versionmapping.DefaultVariantVersionMappingStrategy in project gradle by gradle.
the class DefaultVersionMappingStrategy method createDefaultMappingStrategy.
private DefaultVariantVersionMappingStrategy createDefaultMappingStrategy(ImmutableAttributes variantAttributes) {
DefaultVariantVersionMappingStrategy strategy = new DefaultVariantVersionMappingStrategy(configurations, projectResolver, projectRegistry);
if (!defaultConfigurations.isEmpty()) {
// First need to populate the default variant version mapping strategy with the default values
// provided by plugins
AttributeMatcher matcher = schema.matcher();
Set<ImmutableAttributes> candidates = defaultConfigurations.keySet();
List<ImmutableAttributes> matches = matcher.matches(candidates, variantAttributes, AttributeMatchingExplanationBuilder.NO_OP);
for (ImmutableAttributes match : matches) {
strategy.setTargetConfiguration(configurations.getByName(defaultConfigurations.get(match)));
}
}
return strategy;
}
Aggregations