use of org.gradle.api.artifacts.ComponentMetadata in project gradle by gradle.
the class DefaultComponentMetadataProcessor method processMetadata.
@Override
public ComponentMetadata processMetadata(ComponentMetadata metadata) {
ComponentMetadata updatedMetadata;
if (metadataRuleContainer.isEmpty()) {
updatedMetadata = metadata;
} else {
ShallowComponentMetadataAdapter details = new ShallowComponentMetadataAdapter(componentIdentifierNotationParser, metadata, attributesFactory);
processAllRules(null, details, metadata.getId());
updatedMetadata = details.asImmutable();
}
if (!updatedMetadata.getStatusScheme().contains(updatedMetadata.getStatus())) {
throw new ModuleVersionResolveException(updatedMetadata.getId(), () -> String.format("Unexpected status '%s' specified for %s. Expected one of: %s", updatedMetadata.getStatus(), updatedMetadata.getId().toString(), updatedMetadata.getStatusScheme()));
}
return updatedMetadata;
}
use of org.gradle.api.artifacts.ComponentMetadata 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;
}
use of org.gradle.api.artifacts.ComponentMetadata in project gradle by gradle.
the class DefaultMetadataProvider method computeMetadata.
@Nullable
private ComponentMetadata computeMetadata() {
ComponentMetadata metadata = null;
InstantiatingAction<ComponentMetadataSupplierDetails> componentMetadataSupplier = resolveState.getComponentMetadataSupplier();
if (componentMetadataSupplier != null) {
metadata = getComponentMetadataFromSupplier(componentMetadataSupplier);
}
if (metadata != null) {
metadata = transformThroughComponentMetadataRules(componentMetadataSupplier, metadata);
} else if (resolve()) {
metadata = new ComponentMetadataAdapter(cachedResult.getMetaData());
}
return metadata;
}
use of org.gradle.api.artifacts.ComponentMetadata in project gradle by gradle.
the class DefaultVersionedComponentChooser method tryRejectByAttributes.
@Nullable
private RejectedByAttributesVersion tryRejectByAttributes(ModuleComponentIdentifier id, MetadataProvider provider, ImmutableAttributes consumerAttributes) {
if (consumerAttributes.isEmpty()) {
return null;
}
// At this point, we need the component metadata, because it may declare attributes that are needed for matching
// Component metadata may not necessarily hit the network if there is a custom component metadata supplier
ComponentMetadata componentMetadata = provider.getComponentMetadata();
if (componentMetadata != null) {
AttributeContainerInternal attributes = (AttributeContainerInternal) componentMetadata.getAttributes();
boolean matching = attributesSchema.matcher().isMatching(attributes, consumerAttributes);
if (!matching) {
return new RejectedByAttributesVersion(id, attributesSchema.matcher().describeMatching(attributes, consumerAttributes));
}
}
return null;
}
Aggregations