Search in sources :

Example 1 with ModelPath

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);
    }
}
Also used : ModelPath(org.gradle.model.internal.core.ModelPath) UnmanagedModelProjection(org.gradle.model.internal.core.UnmanagedModelProjection) SimpleModelRuleDescriptor(org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor)

Example 2 with ModelPath

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);
}
Also used : InvalidModelRuleException(org.gradle.model.InvalidModelRuleException) ModelPath(org.gradle.model.internal.core.ModelPath) ModelRuleBindingException(org.gradle.model.ModelRuleBindingException) AmbiguousBindingReporter(org.gradle.model.internal.report.AmbiguousBindingReporter) ModelRuleDescriptor(org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor)

Example 3 with ModelPath

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]);
}
Also used : Path(org.gradle.model.Path) ModelPath(org.gradle.model.internal.core.ModelPath) ModelPath(org.gradle.model.internal.core.ModelPath) Spec(org.gradle.api.specs.Spec) Annotation(java.lang.annotation.Annotation)

Example 4 with ModelPath

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;
}
Also used : UnboundRuleInput(org.gradle.model.internal.report.unbound.UnboundRuleInput) ModelPath(org.gradle.model.internal.core.ModelPath)

Example 5 with ModelPath

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);
}
Also used : ModelPath(org.gradle.model.internal.core.ModelPath) Nullable(org.gradle.api.Nullable)

Aggregations

ModelPath (org.gradle.model.internal.core.ModelPath)8 ModelRuleDescriptor (org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor)2 Annotation (java.lang.annotation.Annotation)1 Nullable (org.gradle.api.Nullable)1 Spec (org.gradle.api.specs.Spec)1 InvalidModelRuleException (org.gradle.model.InvalidModelRuleException)1 ModelRuleBindingException (org.gradle.model.ModelRuleBindingException)1 Path (org.gradle.model.Path)1 DuplicateModelException (org.gradle.model.internal.core.DuplicateModelException)1 UnmanagedModelProjection (org.gradle.model.internal.core.UnmanagedModelProjection)1 SimpleModelRuleDescriptor (org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor)1 AmbiguousBindingReporter (org.gradle.model.internal.report.AmbiguousBindingReporter)1 UnboundRuleInput (org.gradle.model.internal.report.unbound.UnboundRuleInput)1