Search in sources :

Example 1 with IvyModuleResolveMetadata

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

the class DefaultComponentMetadataHandler method processRule.

private void processRule(SpecRuleAction<? super ComponentMetadataDetails> specRuleAction, ModuleComponentResolveMetadata metadata, ComponentMetadataDetails details) {
    if (!specRuleAction.getSpec().isSatisfiedBy(details)) {
        return;
    }
    List<Object> inputs = Lists.newArrayList();
    for (Class<?> inputType : specRuleAction.getAction().getInputTypes()) {
        if (inputType == IvyModuleDescriptor.class) {
            // Ignore the rule if it expects Ivy metadata and this isn't an Ivy module
            if (!(metadata instanceof IvyModuleResolveMetadata)) {
                return;
            }
            IvyModuleResolveMetadata ivyMetadata = (IvyModuleResolveMetadata) metadata;
            inputs.add(new DefaultIvyModuleDescriptor(ivyMetadata.getExtraInfo(), ivyMetadata.getBranch(), ivyMetadata.getStatus()));
            continue;
        }
        // We've already validated the inputs: should never get here.
        throw new IllegalStateException();
    }
    try {
        specRuleAction.getAction().execute(details, inputs);
    } catch (Exception e) {
        throw new InvalidUserCodeException(String.format("There was an error while evaluating a component metadata rule for %s.", details.getId()), e);
    }
}
Also used : DefaultIvyModuleDescriptor(org.gradle.api.internal.artifacts.ivyservice.DefaultIvyModuleDescriptor) InvalidUserCodeException(org.gradle.api.InvalidUserCodeException) IvyModuleResolveMetadata(org.gradle.internal.component.external.model.IvyModuleResolveMetadata) InvalidUserCodeException(org.gradle.api.InvalidUserCodeException) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) UnsupportedNotationException(org.gradle.internal.typeconversion.UnsupportedNotationException)

Aggregations

InvalidUserCodeException (org.gradle.api.InvalidUserCodeException)1 DefaultIvyModuleDescriptor (org.gradle.api.internal.artifacts.ivyservice.DefaultIvyModuleDescriptor)1 IvyModuleResolveMetadata (org.gradle.internal.component.external.model.IvyModuleResolveMetadata)1 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)1 UnsupportedNotationException (org.gradle.internal.typeconversion.UnsupportedNotationException)1