Search in sources :

Example 1 with ComponentMetadataDetails

use of org.gradle.api.artifacts.ComponentMetadataDetails in project gradle by gradle.

the class DefaultComponentMetadataHandler method processMetadata.

public ModuleComponentResolveMetadata processMetadata(ModuleComponentResolveMetadata metadata) {
    ModuleComponentResolveMetadata updatedMetadata;
    if (rules.isEmpty()) {
        updatedMetadata = metadata;
    } else {
        MutableModuleComponentResolveMetadata mutableMetadata = metadata.asMutable();
        ComponentMetadataDetails details = instantiator.newInstance(ComponentMetadataDetailsAdapter.class, mutableMetadata);
        processAllRules(metadata, details);
        updatedMetadata = mutableMetadata.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.getComponentId().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) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) ComponentMetadataDetails(org.gradle.api.artifacts.ComponentMetadataDetails)

Example 2 with ComponentMetadataDetails

use of org.gradle.api.artifacts.ComponentMetadataDetails in project gradle by gradle.

the class DefaultComponentMetadataHandler method createSpecRuleActionForModule.

private SpecRuleAction<? super ComponentMetadataDetails> createSpecRuleActionForModule(Object id, RuleAction<? super ComponentMetadataDetails> ruleAction) {
    ModuleIdentifier moduleIdentifier;
    try {
        moduleIdentifier = moduleIdentifierNotationParser.parseNotation(id);
    } catch (UnsupportedNotationException e) {
        throw new InvalidUserCodeException(String.format(INVALID_SPEC_ERROR, id == null ? "null" : id.toString()), e);
    }
    Spec<ComponentMetadataDetails> spec = new ComponentMetadataDetailsMatchingSpec(moduleIdentifier);
    return new SpecRuleAction<ComponentMetadataDetails>(ruleAction, spec);
}
Also used : InvalidUserCodeException(org.gradle.api.InvalidUserCodeException) SpecRuleAction(org.gradle.internal.rules.SpecRuleAction) UnsupportedNotationException(org.gradle.internal.typeconversion.UnsupportedNotationException) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) ComponentMetadataDetails(org.gradle.api.artifacts.ComponentMetadataDetails)

Aggregations

ComponentMetadataDetails (org.gradle.api.artifacts.ComponentMetadataDetails)2 InvalidUserCodeException (org.gradle.api.InvalidUserCodeException)1 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)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 SpecRuleAction (org.gradle.internal.rules.SpecRuleAction)1 UnsupportedNotationException (org.gradle.internal.typeconversion.UnsupportedNotationException)1