Search in sources :

Example 1 with VariantDerivationStrategy

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

the class DefaultMavenModuleResolveMetadata method getDerivedVariants.

private ImmutableList<? extends ConfigurationMetadata> getDerivedVariants() {
    VariantDerivationStrategy strategy = getVariantDerivationStrategy();
    if (derivedVariants == null && strategy.derivesVariants()) {
        filterConstraints = false;
        derivedVariants = strategy.derive(this);
    }
    return derivedVariants;
}
Also used : VariantDerivationStrategy(org.gradle.internal.component.external.model.VariantDerivationStrategy)

Example 2 with VariantDerivationStrategy

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

the class DefaultComponentMetadataProcessor method processMetadata.

@Override
public ModuleComponentResolveMetadata processMetadata(ModuleComponentResolveMetadata origin) {
    VariantDerivationStrategy curStrategy = metadataRuleContainer.getVariantDerivationStrategy();
    ModuleComponentResolveMetadata metadata = origin.withDerivationStrategy(curStrategy);
    ModuleComponentResolveMetadata updatedMetadata;
    if (metadataRuleContainer.isEmpty()) {
        updatedMetadata = maybeForceRealisation(metadata);
    } else if (metadataRuleContainer.isClassBasedRulesOnly()) {
        Action<ComponentMetadataContext> action = collectRulesAndCreateAction(metadataRuleContainer.getOnlyClassRules(), metadata.getModuleVersionId(), metadataResolutionContext.getInjectingInstantiator());
        if (action instanceof InstantiatingAction) {
            InstantiatingAction<ComponentMetadataContext> ia = (InstantiatingAction<ComponentMetadataContext>) action;
            if (shouldCacheComponentMetadataRule(ia, metadata)) {
                updatedMetadata = processClassRuleWithCaching(ia, metadata, metadataResolutionContext);
            } else {
                MutableModuleComponentResolveMetadata mutableMetadata = metadata.asMutable();
                processClassRule(action, metadata, createDetails(mutableMetadata));
                updatedMetadata = maybeForceRealisation(mutableMetadata.asImmutable());
            }
        } else {
            updatedMetadata = maybeForceRealisation(metadata);
        }
    } else {
        MutableModuleComponentResolveMetadata mutableMetadata = metadata.asMutable();
        ComponentMetadataDetails details = createDetails(mutableMetadata);
        processAllRules(metadata, details, metadata.getModuleVersionId());
        updatedMetadata = maybeForceRealisation(mutableMetadata.asImmutable());
    }
    if (!updatedMetadata.getStatusScheme().contains(updatedMetadata.getStatus())) {
        throw new ModuleVersionResolveException(updatedMetadata.getModuleVersionId(), () -> String.format("Unexpected status '%s' specified for %s. Expected one of: %s", updatedMetadata.getStatus(), updatedMetadata.getId().getDisplayName(), updatedMetadata.getStatusScheme()));
    }
    return updatedMetadata;
}
Also used : MutableModuleComponentResolveMetadata(org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata) MutableModuleComponentResolveMetadata(org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata) ModuleComponentResolveMetadata(org.gradle.internal.component.external.model.ModuleComponentResolveMetadata) Action(org.gradle.api.Action) InstantiatingAction(org.gradle.internal.action.InstantiatingAction) RuleAction(org.gradle.internal.rules.RuleAction) SpecRuleAction(org.gradle.internal.rules.SpecRuleAction) ComponentMetadataContext(org.gradle.api.artifacts.ComponentMetadataContext) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) VariantDerivationStrategy(org.gradle.internal.component.external.model.VariantDerivationStrategy) InstantiatingAction(org.gradle.internal.action.InstantiatingAction) ComponentMetadataDetails(org.gradle.api.artifacts.ComponentMetadataDetails)

Aggregations

VariantDerivationStrategy (org.gradle.internal.component.external.model.VariantDerivationStrategy)2 Action (org.gradle.api.Action)1 ComponentMetadataContext (org.gradle.api.artifacts.ComponentMetadataContext)1 ComponentMetadataDetails (org.gradle.api.artifacts.ComponentMetadataDetails)1 InstantiatingAction (org.gradle.internal.action.InstantiatingAction)1 ModuleComponentResolveMetadata (org.gradle.internal.component.external.model.ModuleComponentResolveMetadata)1 MutableModuleComponentResolveMetadata (org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata)1 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)1 RuleAction (org.gradle.internal.rules.RuleAction)1 SpecRuleAction (org.gradle.internal.rules.SpecRuleAction)1