Operations 5 min read

How to Keep Gradle Running All Tasks Even When Some Fail

This guide explains the Gradle --continue option, shows a sample build script with a deliberately failing task, demonstrates command‑line runs with and without the flag, and reveals how Gradle executes remaining tasks while reporting all failures.

FunTester
FunTester
FunTester
How to Keep Gradle Running All Tasks Even When Some Fail

Gradle stops the entire build as soon as any task fails, providing fast feedback. If you want the build to continue executing all tasks regardless of individual failures, you can use the command‑line option --continue. With this flag, Gradle runs every task whose dependencies have not failed, which is especially useful in multi‑module projects where you may still want to see test results from all modules.

Sample build script

task failTask << {
    println "Running ${task.name}"
    throw new TaskExecutionException(
            task,
            new Exception('Fail task on purpose'))
}

task successTask << {
    println "Running ${it.name}"
}

The script defines two tasks: failTask, which intentionally throws a TaskExecutionException, and successTask, which simply prints a message and never fails.

Running without --continue

$ gradle failTask successTask
:failTask
Running failTask
:failTask FAILED

FAILURE: Build failed with an exception.
* Where:
Build file '/Users/mrhaki/samples/gradle/continue/build.gradle' line: 4
* What went wrong:
Execution failed for task ':failTask'.
> Fail task on purpose
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.148 secs

Only failTask runs; the build stops immediately after its failure, and successTask is never executed.

Running with --continue

$ gradle --continue failTask successTask
:failTask
Running failTask
:failTask FAILED
:successTask
Running successTask

FAILURE: Build failed with an exception.
* Where:
Build file '/Users/mrhaki/samples/gradle/continue/build.gradle' line: 4
* What went wrong:
Execution failed for task ':failTask'.
> Fail task on purpose
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 6.918 secs

With --continue, Gradle still reports the failure of failTask but proceeds to execute successTask. After the build finishes, Gradle provides a summary of all failed tasks, allowing you to see the full picture of which modules succeeded and which did not.

This behavior is valuable for comprehensive testing across large projects, where you may want to collect all test results even if some tests fail.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Build AutomationDevOpsGradletask failurecontinue option
FunTester
Written by

FunTester

10k followers, 1k articles | completely useless

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.