use of org.gradle.model.internal.core.ModelPath in project gradle by gradle.
the class DefaultTaskContainer method addPlaceholderAction.
public <T extends TaskInternal> void addPlaceholderAction(final String placeholderName, final Class<T> taskType, final Action<? super T> configure) {
if (!modelNode.hasLink(placeholderName)) {
final ModelType<T> taskModelType = ModelType.of(taskType);
ModelPath path = MODEL_PATH.child(placeholderName);
modelNode.addLink(ModelRegistrations.of(path).action(ModelActionRole.Create, new TaskCreator<T>(placeholderName, taskType, configure, taskModelType)).withProjection(new UnmanagedModelProjection<T>(taskModelType)).descriptor(new SimpleModelRuleDescriptor("tasks.addPlaceholderAction(" + placeholderName + ")")).build());
}
if (findByNameWithoutRules(placeholderName) == null) {
placeholders.add(placeholderName);
}
}
use of org.gradle.model.internal.core.ModelPath in project gradle by gradle.
the class ModelBinding method onBind.
public final void onBind(ModelNodeInternal node) {
if (boundTo != null) {
ModelRuleDescriptor creatorDescriptor = node.getDescriptor();
ModelPath path = node.getPath();
throw new InvalidModelRuleException(referrer, new ModelRuleBindingException(new AmbiguousBindingReporter(predicate.getReference(), boundTo.getPath(), boundTo.getDescriptor(), path, creatorDescriptor).asString()));
}
doOnBind(node);
}
use of org.gradle.model.internal.core.ModelPath in project gradle by gradle.
the class DefaultMethodRuleDefinition method reference.
private ModelReference<?> reference(List<Annotation> annotations, int i) {
Path pathAnnotation = (Path) findFirst(annotations, new Spec<Annotation>() {
public boolean isSatisfiedBy(Annotation element) {
return element.annotationType().equals(Path.class);
}
});
ModelPath path = pathAnnotation == null ? null : ModelPath.path(pathAnnotation.value());
ModelType<?> cast = method.getGenericParameterTypes().get(i);
return ModelReference.of(path, cast, PARAMETER_DESC[i]);
}
use of org.gradle.model.internal.core.ModelPath in project gradle by gradle.
the class UnboundRulesProcessor method toInputBuilder.
private UnboundRuleInput.Builder toInputBuilder(ModelBinding binding) {
ModelReference<?> reference = binding.getPredicate().getReference();
UnboundRuleInput.Builder builder = UnboundRuleInput.type(reference.getType());
ModelPath path;
if (binding.isBound()) {
builder.bound();
path = binding.getNode().getPath();
} else {
path = reference.getPath();
if (path != null) {
builder.suggestions(CollectionUtils.stringize(suggestionsProvider.transform(path)));
}
ModelPath scope = reference.getScope();
if (scope != null && !scope.equals(ModelPath.ROOT)) {
builder.scope(scope.toString());
}
}
if (path != null) {
builder.path(path);
}
builder.description(reference.getDescription());
return builder;
}
use of org.gradle.model.internal.core.ModelPath in project gradle by gradle.
the class AbstractModelCreationRuleExtractor method registration.
@Nullable
@Override
public <R, S> ExtractedModelRule registration(MethodRuleDefinition<R, S> ruleDefinition, MethodModelRuleExtractionContext context) {
ModelPath modelPath = determineModelName(ruleDefinition, context);
validateMethod(ruleDefinition, context);
if (context.hasProblems()) {
return null;
}
return buildRule(modelPath, ruleDefinition);
}
Aggregations