Search in sources :

Example 1 with TaskExecutionException

use of org.gradle.api.tasks.TaskExecutionException in project gradle by gradle.

the class VerifyNoInputChangesTaskExecuter method execute.

@Override
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    TaskOutputCachingBuildCacheKey beforeExecution = context.getBuildCacheKey();
    delegate.execute(task, state, context);
    if (beforeExecution.isValid()) {
        TaskOutputCachingBuildCacheKey afterExecution = repository.getStateFor(task).calculateCacheKey();
        if (!afterExecution.isValid()) {
            throw new TaskExecutionException(task, new GradleException("The build cache key became invalid after the task has been executed!"));
        }
        if (!beforeExecution.getHashCode().equals(afterExecution.getHashCode())) {
            throw new TaskExecutionException(task, new GradleException("The inputs for the task changed during the execution! Check if you have a `doFirst` changing the inputs."));
        }
    }
}
Also used : TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) GradleException(org.gradle.api.GradleException) TaskOutputCachingBuildCacheKey(org.gradle.caching.internal.tasks.TaskOutputCachingBuildCacheKey)

Example 2 with TaskExecutionException

use of org.gradle.api.tasks.TaskExecutionException in project gradle by gradle.

the class DefaultTaskProperties method resolve.

public static TaskProperties resolve(PropertyWalker propertyWalker, PathToFileResolver resolver, TaskInternal task) {
    String beanName = task.toString();
    GetInputFilesVisitor inputFilesVisitor = new GetInputFilesVisitor();
    GetOutputFilesVisitor outputFilesVisitor = new GetOutputFilesVisitor();
    GetInputPropertiesVisitor inputPropertiesVisitor = new GetInputPropertiesVisitor(beanName);
    GetLocalStateVisitor localStateVisitor = new GetLocalStateVisitor(beanName, resolver);
    GetDestroyablesVisitor destroyablesVisitor = new GetDestroyablesVisitor(beanName, resolver);
    ValidationVisitor validationVisitor = new ValidationVisitor();
    try {
        TaskPropertyUtils.visitProperties(propertyWalker, task, new CompositePropertyVisitor(inputPropertiesVisitor, inputFilesVisitor, outputFilesVisitor, validationVisitor, destroyablesVisitor, localStateVisitor));
    } catch (Exception e) {
        throw new TaskExecutionException(task, e);
    }
    return new DefaultTaskProperties(task.toString(), inputPropertiesVisitor.getPropertyValuesFactory(), inputFilesVisitor.getFileProperties(), outputFilesVisitor.getFileProperties(), outputFilesVisitor.hasDeclaredOutputs(), localStateVisitor.getFiles(), destroyablesVisitor.getFiles(), validationVisitor.getTaskPropertySpecs());
}
Also used : GetInputFilesVisitor(org.gradle.api.internal.tasks.properties.GetInputFilesVisitor) TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) GetInputPropertiesVisitor(org.gradle.api.internal.tasks.properties.GetInputPropertiesVisitor) GetOutputFilesVisitor(org.gradle.api.internal.tasks.properties.GetOutputFilesVisitor) TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) CompositePropertyVisitor(org.gradle.api.internal.tasks.properties.CompositePropertyVisitor)

Example 3 with TaskExecutionException

use of org.gradle.api.tasks.TaskExecutionException 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 4 with TaskExecutionException

use of org.gradle.api.tasks.TaskExecutionException in project azure-gradle-plugins by lenala.

the class PackageTask method packageFunction.

@TaskAction
void packageFunction() {
    try {
        final AnnotationHandler handler = getAnnotationHandler();
        final Set<Method> methods = findAnnotatedMethods(handler);
        final Map<String, FunctionConfiguration> configMap = getFunctionConfigurations(handler, methods);
        validateFunctionConfigurations(configMap);
        final ObjectWriter objectWriter = getObjectWriter();
        writeEmptyHostJsonFile(objectWriter);
        copyLocalSettingsJson();
        writeFunctionJsonFiles(objectWriter, configMap);
        copyJarsToStageDirectory();
        getLogger().quiet(BUILD_SUCCESS);
    } catch (Exception ex) {
        throw new TaskExecutionException(this, ex);
    }
}
Also used : TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) FunctionConfiguration(com.microsoft.azure.gradle.functions.configuration.FunctionConfiguration) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) AnnotationHandler(com.microsoft.azure.gradle.functions.handlers.AnnotationHandler) Method(java.lang.reflect.Method) TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) IOException(java.io.IOException) TaskAction(org.gradle.api.tasks.TaskAction)

Example 5 with TaskExecutionException

use of org.gradle.api.tasks.TaskExecutionException in project azure-gradle-plugins by lenala.

the class DeployTask method deploy.

@TaskAction
void deploy() {
    try {
        getLogger().quiet(String.format(WEBAPP_DEPLOY_START, azureWebAppExtension.getAppName()));
        createOrUpdateWebApp();
        deployArtifacts();
        getLogger().quiet(String.format(WEBAPP_DEPLOY_SUCCESS, azureWebAppExtension.getAppName()));
    } catch (Exception ex) {
        throw new TaskExecutionException(this, ex);
    }
}
Also used : TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) AzureAuthFailureException(com.microsoft.azure.gradle.webapp.auth.AzureAuthFailureException) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

TaskExecutionException (org.gradle.api.tasks.TaskExecutionException)20 TaskAction (org.gradle.api.tasks.TaskAction)9 IOException (java.io.IOException)5 File (java.io.File)3 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 GradleException (org.gradle.api.GradleException)2 GradleScriptException (org.gradle.api.GradleScriptException)2 TaskInternal (org.gradle.api.internal.TaskInternal)2 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)2 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)2 Test (org.junit.Test)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 GsonBuilder (com.google.gson.GsonBuilder)1 FunctionConfiguration (com.microsoft.azure.gradle.functions.configuration.FunctionConfiguration)1 AnnotationHandler (com.microsoft.azure.gradle.functions.handlers.AnnotationHandler)1 FunctionTemplate (com.microsoft.azure.gradle.functions.template.FunctionTemplate)1 AzureAuthFailureException (com.microsoft.azure.gradle.webapp.auth.AzureAuthFailureException)1