If we run a Gradle build and one of the tasks fails, the whole build stops immediately. So we have fast feedback of our build status. If we don't want to this and want Gradle to execute all tasks, even though some might have failed, we use the command line option --continue. When we use the --continue command line option Gradle will execute every task where the dependent tasks are not failing. This is also useful in a multi-module project where we might want to build all projects even though some may have failing tests, so we get a complete overview of failed tests for all modules.

In the following Gradle build file we have two tasks. The task failTask throws a TaskExecutionException to purposely fail the task. The successTask will not fail:

00.task failTask << { task ->
01.println "Running ${task.name}"
02. 
03.throw new TaskExecutionException(
04.task,
05.new Exception('Fail task on purpose'))
06.}
07. 
08.task successTask << {
09.println "Running ${it.name}"
10.}

Let's run both tasks from the command line and see the output:

$ 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
$

We see the build has failed and only the task failTask is executed. Now we run the same two tasks, but we use the command line option --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
$

This time the successTask is executed even though the failTask has failed again. Gradle will keep track of all tasks that have failed and displays a summary with all the tasks that have failed.

Written with Gradle 2.2.1

Gradle Goodness: Continue Build Even with Failed Tasks的更多相关文章

  1. Gradle Goodness: Display Available Tasks

    To see which tasks are available for our build we can run Gradle with the command-line option -t or ...

  2. Gradle Goodness: Run a Build Script With a Different Name

    Normally Gradle looks for a build script file with the name build.gradle in the current directory to ...

  3. Gradle Goodness: Group Similar Tasks

    In Gradle we can assign a task to a group. Gradle uses the group for example in the output of $ grad ...

  4. Gradle Goodness: Task Output Annotations Create Directory Automatically

    Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of ...

  5. Gradle Goodness: Init Script for Adding Extra Plugins to Existing Projects

    Gradle Goodness: Init Script for Adding Extra Plugins to Existing Projects Gradle is very flexible. ...

  6. Gradle Goodness: Using and Working with Gradle Version

    To get the current Gradle version we can use the gradleVersion property of the Gradle object. This r ...

  7. Gradle Goodness: Skip Building Project Dependencies

    If we use Gradle in a multi-module project we can define project dependencies between modules. Gradl ...

  8. cordova build android Command failed with exit code EACCES

    问题: 执行cordova build android 出现输出如下,编译不成功. ANDROID_HOME=/Users/huangenai/Library/Android/sdkJAVA_HOME ...

  9. Gradle Goodness: Copy Files with Filtering

    Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filterin ...

随机推荐

  1. MVVMLight leaning note

    Learning Note For MvvmLight MvvmLight quitstart refer link1 : MVVMLight HelloWorld *** mc:Ignorable ...

  2. 可综合风格的VerilogHDL模块实例

    1.赋值语句:assign{cout,sum}=a+b+cin; 2.利用电平敏感的always块设计组合逻辑电路 3.always块中如果含有局部变量,就必须在begin后加模块名,是必须加,同样的 ...

  3. OC学习笔记之属性详解和易错点

    属性的概念在OC1.0中就存在,格式是定义实例变量,然后定义setter和getter方法,用点操作符操作属性 举例,类的接口部分 @interface Father : NSObject { NSI ...

  4. word2007中如何隐藏工具栏

    1.对于屏幕较小的用户来说,编辑时可能需要隐藏word上方的工具栏,具体操作如下:

  5. “我爱淘”冲刺阶段Scrum站立会议10

    完成任务: 完成了webservice的配置与测试,可以将数据库中的内容解析出来. 计划任务: 在客户端通过查询可以得到想要的书籍内容. 遇到问题: 客户端的内容获取还没有实现.

  6. opencv 2.4.9+pcl 1.6+vs2010+win7 32开发环境配置

    最近在做图像方面的开发,需要对软件开发平台进行配置,我查找了关于这些方面的内容,由于软件版本很多,每个人的开发平台又不一样所以在对平台进行搭建过程中遇到了很多问题,下面我将我搭建平台的流程做一个记录. ...

  7. 一些常用到的Centos命令

    CentOS常用命令在我们的使用中,经常被使用.所以,我们对一些经常使用又很重要的CentOS常用命令进行了全面的整理.下面,就来介绍这些CentOS常用命令. 一:使用CentOS常用命令查看cpu ...

  8. 查看JVM内存

    你知道如何进行JVM内存查看,这里和大家分享几个JVM内存查看方法,希望对你的学习有所帮助,通常情况下可以用代码查看,也可以在eclipse中增添相关信息后直接查看. JVM内存查看方法 可以用代码查 ...

  9. 【WildCard Matching】cpp

    题目: Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single charact ...

  10. 学习Linux第四天

    ---恢复内容开始--- 1.常用的命令: reset 清屏 leave +hhmm 建立离开提醒 sudo apt-get yum 安装yum程序 sudo su 切换root身份 see test ...