Search in sources :

Example 1 with TaskExecuterResult

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

Aggregations

List (java.util.List)1 Optional (java.util.Optional)1 TaskInternal (org.gradle.api.internal.TaskInternal)1 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)1 FileOperations (org.gradle.api.internal.file.FileOperations)1 TaskExecuter (org.gradle.api.internal.tasks.TaskExecuter)1 TaskExecuterResult (org.gradle.api.internal.tasks.TaskExecuterResult)1 TaskExecutionContext (org.gradle.api.internal.tasks.TaskExecutionContext)1 TaskExecutionOutcome (org.gradle.api.internal.tasks.TaskExecutionOutcome)1 TaskStateInternal (org.gradle.api.internal.tasks.TaskStateInternal)1 TaskExecutionException (org.gradle.api.tasks.TaskExecutionException)1 OriginMetadata (org.gradle.caching.internal.origin.OriginMetadata)1 ListenerManager (org.gradle.internal.event.ListenerManager)1 ExecutionEngine (org.gradle.internal.execution.ExecutionEngine)1 Result (org.gradle.internal.execution.ExecutionEngine.Result)1 ExecutionOutcome (org.gradle.internal.execution.ExecutionOutcome)1 WorkValidationException (org.gradle.internal.execution.WorkValidationException)1 CachingState (org.gradle.internal.execution.caching.CachingState)1 InputFingerprinter (org.gradle.internal.execution.fingerprint.InputFingerprinter)1 ExecutionHistoryStore (org.gradle.internal.execution.history.ExecutionHistoryStore)1