use of org.gradle.model.internal.core.ModelAction in project gradle by gradle.
the class RuleExtractorUtils method configureRuleAction.
public static void configureRuleAction(MethodModelRuleApplicationContext context, RuleApplicationScope ruleApplicationScope, ModelActionRole role, MethodRuleAction ruleAction) {
ModelAction action = context.contextualize(ruleAction);
ModelRegistry registry = context.getRegistry();
switch(ruleApplicationScope) {
case SELF:
registry.configure(role, action);
break;
case DESCENDANTS:
registry.configureMatching(new NonReferenceDescendantsSpec(context.getScope()), role, action);
break;
default:
throw new AssertionError();
}
}
use of org.gradle.model.internal.core.ModelAction in project gradle by gradle.
the class DefaultModelRegistry method fireAction.
private void fireAction(RuleBinder boundMutator) {
final List<ModelView<?>> inputs = toViews(boundMutator.getInputBindings(), boundMutator.getAction().getDescriptor());
ModelBinding subjectBinding = boundMutator.getSubjectBinding();
final ModelNodeInternal node = subjectBinding.getNode();
final ModelAction mutator = boundMutator.getAction();
ModelRuleDescriptor descriptor = mutator.getDescriptor();
LOGGER.debug("Project {} - Mutating {} using {}", projectPath, node.getPath(), descriptor);
try {
RuleContext.run(descriptor, new Runnable() {
@Override
public void run() {
mutator.execute(node, inputs);
}
});
} catch (Throwable e) {
// TODO some representation of state of the inputs
throw new ModelRuleExecutionException(descriptor, e);
}
}
use of org.gradle.model.internal.core.ModelAction in project gradle by gradle.
the class DefaultModelRegistry method addRuleBindings.
private void addRuleBindings(ModelNodeInternal node, Multimap<ModelActionRole, ? extends ModelAction> actions) {
for (Map.Entry<ModelActionRole, ? extends ModelAction> entry : actions.entries()) {
ModelActionRole role = entry.getKey();
ModelAction action = entry.getValue();
checkNodePath(node, action);
RuleBinder binder = bindInternal(action.getSubject(), role, action);
node.addRegistrationActionBinder(binder);
}
}
Aggregations