use of org.gradle.internal.action.InstantiatingAction 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;
}
use of org.gradle.internal.action.InstantiatingAction in project gradle by gradle.
the class DefaultMetadataProvider method getComponentMetadataFromSupplier.
private ComponentMetadata getComponentMetadataFromSupplier(InstantiatingAction<ComponentMetadataSupplierDetails> componentMetadataSupplier) {
ComponentMetadata metadata;
ModuleVersionIdentifier id = DefaultModuleVersionIdentifier.newId(resolveState.getId());
metadata = resolveState.getComponentMetadataSupplierExecutor().execute(id, componentMetadataSupplier, TO_COMPONENT_METADATA, id1 -> {
final SimpleComponentMetadataBuilder builder = new SimpleComponentMetadataBuilder(id1, resolveState.getAttributesFactory());
return new BuildableComponentMetadataSupplierDetails(builder);
}, resolveState.getCachePolicy());
return metadata;
}
Aggregations