Search in sources :

Example 1 with DefaultTaskValidationContext

use of org.gradle.api.internal.tasks.DefaultTaskValidationContext in project gradle by gradle.

the class ValidatingTaskExecuter method execute.

public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    List<String> messages = Lists.newArrayList();
    FileResolver resolver = ((ProjectInternal) task.getProject()).getFileResolver();
    final TaskValidationContext validationContext = new DefaultTaskValidationContext(resolver, messages);
    try {
        context.getTaskProperties().validate(validationContext);
    } catch (Exception ex) {
        throw new TaskExecutionException(task, ex);
    }
    if (!messages.isEmpty()) {
        List<String> firstMessages = messages.subList(0, Math.min(5, messages.size()));
        if (!validationContext.getHighestSeverity().report(task, firstMessages, state)) {
            return;
        }
    }
    executer.execute(task, state, context);
}
Also used : TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) DefaultTaskValidationContext(org.gradle.api.internal.tasks.DefaultTaskValidationContext) TaskValidationContext(org.gradle.api.internal.tasks.TaskValidationContext) DefaultTaskValidationContext(org.gradle.api.internal.tasks.DefaultTaskValidationContext) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) FileResolver(org.gradle.api.internal.file.FileResolver) TaskExecutionException(org.gradle.api.tasks.TaskExecutionException)

Example 2 with DefaultTaskValidationContext

use of org.gradle.api.internal.tasks.DefaultTaskValidationContext in project gradle by gradle.

the class TaskExecution method validate.

@Override
public void validate(WorkValidationContext validationContext) {
    Class<?> taskType = GeneratedSubclasses.unpackType(task);
    // TODO This should probably use the task class info store
    boolean cacheable = taskType.isAnnotationPresent(CacheableTask.class);
    TypeValidationContext typeValidationContext = validationContext.forType(taskType, cacheable);
    context.getTaskProperties().validateType(typeValidationContext);
    context.getTaskProperties().validate(new DefaultTaskValidationContext(fileOperations, reservedFileSystemLocationRegistry, typeValidationContext));
    context.getValidationAction().validate(context.getTaskExecutionMode().isTaskHistoryMaintained(), typeValidationContext);
}
Also used : DefaultTaskValidationContext(org.gradle.api.internal.tasks.DefaultTaskValidationContext) TypeValidationContext(org.gradle.internal.reflect.validation.TypeValidationContext)

Aggregations

DefaultTaskValidationContext (org.gradle.api.internal.tasks.DefaultTaskValidationContext)2 FileResolver (org.gradle.api.internal.file.FileResolver)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 TaskValidationContext (org.gradle.api.internal.tasks.TaskValidationContext)1 TaskExecutionException (org.gradle.api.tasks.TaskExecutionException)1 TypeValidationContext (org.gradle.internal.reflect.validation.TypeValidationContext)1