Search in sources :

Example 1 with TaskValidationContext

use of org.gradle.api.internal.tasks.TaskValidationContext 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)

Aggregations

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