Search in sources :

Example 16 with TaskExecutionException

use of org.gradle.api.tasks.TaskExecutionException in project spring-boot by spring-projects.

the class MavenExec method exec.

@Override
public void exec() {
    workingDir(this.projectDir);
    systemProperty("maven.multiModuleProjectDirectory", this.projectDir.getAbsolutePath());
    try {
        Path logFile = Files.createTempFile(getName(), ".log");
        try {
            args("--log-file", logFile.toFile().getAbsolutePath());
            super.exec();
            if (this.log.isInfoEnabled()) {
                Files.readAllLines(logFile).forEach(this.log::info);
            }
        } catch (ExecException ex) {
            System.out.println("Exec exception! Dumping log");
            Files.readAllLines(logFile).forEach(System.out::println);
            throw ex;
        }
    } catch (IOException ex) {
        throw new TaskExecutionException(this, ex);
    }
}
Also used : Path(java.nio.file.Path) TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) ExecException(org.gradle.process.internal.ExecException) IOException(java.io.IOException)

Example 17 with TaskExecutionException

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

the class ExecuteActionsTaskExecuter method executeIfValid.

private TaskExecuterResult executeIfValid(TaskInternal task, TaskStateInternal state, TaskExecutionContext context, TaskExecution work) {
    ExecutionEngine.Request request = executionEngine.createRequest(work);
    context.getTaskExecutionMode().getRebuildReason().ifPresent(request::forceNonIncremental);
    request.withValidationContext(context.getValidationContext());
    Result result = request.execute();
    result.getExecutionResult().ifSuccessfulOrElse(executionResult -> state.setOutcome(TaskExecutionOutcome.valueOf(executionResult.getOutcome())), failure -> state.setOutcome(new TaskExecutionException(task, failure)));
    return new TaskExecuterResult() {

        @Override
        public Optional<OriginMetadata> getReusedOutputOriginMetadata() {
            return result.getReusedOutputOriginMetadata();
        }

        @Override
        public boolean executedIncrementally() {
            return result.getExecutionResult().map(executionResult -> executionResult.getOutcome() == ExecutionOutcome.EXECUTED_INCREMENTALLY).getOrMapFailure(throwable -> false);
        }

        @Override
        public List<String> getExecutionReasons() {
            return result.getExecutionReasons();
        }

        @Override
        public CachingState getCachingState() {
            return result.getCachingState();
        }
    };
}
Also used : TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) Result(org.gradle.internal.execution.ExecutionEngine.Result) WorkValidationException(org.gradle.internal.execution.WorkValidationException) TaskInternal(org.gradle.api.internal.TaskInternal) ListenerManager(org.gradle.internal.event.ListenerManager) ExecutionOutcome(org.gradle.internal.execution.ExecutionOutcome) TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) TaskExecuterResult(org.gradle.api.internal.tasks.TaskExecuterResult) TaskStateInternal(org.gradle.api.internal.tasks.TaskStateInternal) AsyncWorkTracker(org.gradle.internal.work.AsyncWorkTracker) ClassLoaderHierarchyHasher(org.gradle.internal.hash.ClassLoaderHierarchyHasher) TaskExecutionContext(org.gradle.api.internal.tasks.TaskExecutionContext) ExecutionEngine(org.gradle.internal.execution.ExecutionEngine) List(java.util.List) InputFingerprinter(org.gradle.internal.execution.fingerprint.InputFingerprinter) FileCollectionFactory(org.gradle.api.internal.file.FileCollectionFactory) ExecutionHistoryStore(org.gradle.internal.execution.history.ExecutionHistoryStore) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor) TaskExecuter(org.gradle.api.internal.tasks.TaskExecuter) FileOperations(org.gradle.api.internal.file.FileOperations) Optional(java.util.Optional) TaskExecutionOutcome(org.gradle.api.internal.tasks.TaskExecutionOutcome) OriginMetadata(org.gradle.caching.internal.origin.OriginMetadata) CachingState(org.gradle.internal.execution.caching.CachingState) ReservedFileSystemLocationRegistry(org.gradle.internal.file.ReservedFileSystemLocationRegistry) ExecutionEngine(org.gradle.internal.execution.ExecutionEngine) TaskExecuterResult(org.gradle.api.internal.tasks.TaskExecuterResult) OriginMetadata(org.gradle.caching.internal.origin.OriginMetadata) Result(org.gradle.internal.execution.ExecutionEngine.Result) TaskExecuterResult(org.gradle.api.internal.tasks.TaskExecuterResult)

Example 18 with TaskExecutionException

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

the class AddTask method add.

@TaskAction
void add() {
    try {
        final List<FunctionTemplate> templates = loadAllFunctionTemplates();
        final FunctionTemplate template = getFunctionTemplate(templates);
        final Map params = prepareRequiredParameters(template);
        final String newFunctionClass = substituteParametersInTemplate(template, params);
        saveNewFunctionToFile(newFunctionClass);
    } catch (Exception ex) {
        throw new TaskExecutionException(this, ex);
    }
}
Also used : TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) FunctionTemplate(com.microsoft.azure.gradle.functions.template.FunctionTemplate) HashMap(java.util.HashMap) Map(java.util.Map) TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException) TaskAction(org.gradle.api.tasks.TaskAction)

Example 19 with TaskExecutionException

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

the class DeployTask method deployFunction.

@TaskAction
void deployFunction() {
    try {
        getLogger().quiet(FUNCTION_DEPLOY_START + getAppName() + "...");
        createOrUpdateFunctionApp();
        getArtifactHandler().publish();
        getLogger().quiet(String.format(FUNCTION_DEPLOY_SUCCESS, getAppName()));
    } catch (Exception ex) {
        throw new TaskExecutionException(this, ex);
    }
}
Also used : TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) TaskAction(org.gradle.api.tasks.TaskAction)

Example 20 with TaskExecutionException

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

the class RunTask method runFunction.

@TaskAction
void runFunction() {
    try {
        checkStageDirectoryExistence();
        checkRuntimeExistence();
        runFunctions();
    } catch (Exception ex) {
        throw new TaskExecutionException(this, ex);
    }
}
Also used : TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) 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