use of org.gradle.api.artifacts.ComponentMetadataContext 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;
}
Aggregations