Gradle Goodness: Continue Build Even with Failed Tasks
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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Gradle Goodness: Task Output Annotations Create Directory Automatically
Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of ...
- 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. ...
- 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 ...
- Gradle Goodness: Skip Building Project Dependencies
If we use Gradle in a multi-module project we can define project dependencies between modules. Gradl ...
- cordova build android Command failed with exit code EACCES
问题: 执行cordova build android 出现输出如下,编译不成功. ANDROID_HOME=/Users/huangenai/Library/Android/sdkJAVA_HOME ...
- Gradle Goodness: Copy Files with Filtering
Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filterin ...
随机推荐
- libcurl 安装使用一
一.下载libcurl http://curl.haxx.se/download/curl-7.21.1.tar.gz 二.安装 指定了安装目录 /usr/local/curl 命令1: ...
- 创建jira插件
准备环境.安装SDK https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and- ...
- IOS之表视图添加索引
我们要实现的效果如下. 1.修改ControlView.h,即添加变量dict,用于存储TabelView的数据源. #import <UIKit/UIKit.h> @interface ...
- Swift TabeleViewCell dequeueReusableCellWithIdentifier 使用的新的细节,原来现在可以这样
今天在看官方的TableView Guide,突然想起来最近写的一个代码中实现tableViewCell复用的时候有点问题: var cell = UITableViewCell(style: UIT ...
- 微软职位内部推荐-SW Engineer II for Cloud Servi
微软近期Open的职位: Do you have a passion for embedded devices and services?   Does the following m ...
- mysql 存储过程 -- 游标的使用(备忘)
BEGIN ; DECLARE f_ratio FLOAT DEFAULT 0.8; ); ); DECLARE i_statDate DATE; DECLARE i_accumulateCount ...
- 【长期兼职】每天3小时写作=每月4000元外快(IT兼职写手)
只要你有经验,每周平均有20来个小时的兼职时间. 只要你愿意静静地写一些心得总结. 那么就可以联系我QQ164349714,敲门:写作. 地址不限.特长不限.学历不限.年龄不限. 主要写作方向:1.投 ...
- 802.11 wireless 五
802.11 wireless 5CSMA/CA,采用倒计时的方法,退避的时间(当年时间+duration 为发送时间,每一个帧会有一个duration,这个位叫做duration[n.持续]) PS ...
- Leetcode#49 Anagrams
原题地址 Anagram:变位词.两个单词是变位词关系的条件是:组成单词的字符相同,只是顺序不同 第一次看这道题看了半天没明白要干嘛,丫就不能给个样例输入输出么..后来还是看网上其他人的总结知道是怎么 ...
- map初始化定时器
init_timer(); //各种定时器的初始化 void Map::init_timer() { //auto tf = GetPlug(TimerFactory); auto tf = m_sp ...