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 ...
随机推荐
- 官方的objective - c风格指南。
The official raywenderlich.com Objective-C style guide. This style guide outlines the coding convent ...
- 关于DataSource的一些记录
今天看WWDC的232_hd_advanced_user_interfaces_with_collection_views,里面花了一般的时间来讲如何合理的设计程序的datesource,将的很有道理 ...
- 35.在PCB中删除元件
在PCB Editor里面,如果想进行什么操作,首先得点击这个命令,再点击你要操作的区域/元件,最后右键选择"Done",这样你才能完成一个操作.
- 微软职位内部推荐-SW Engineer II for Cloud Servi
微软近期Open的职位: Do you have a passion for embedded devices and services?   Does the following m ...
- Android基础整理之四大组件Activity
最近准备系统的重新整理复习一下Android的各方面的知识,本着知识分享的原则,我就把梳理过程中一些东西给记录下来,权当一个学习笔记吧. 下面步入正题..... 什么是Activity Activit ...
- Java令牌生成器
package Token; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; im ...
- ffmpeg 命令
1.保存文件: ffmpeg -i rtsp://admin:12345@172.29.61.108/Streaming/Channels/1 -vcodec copy -acodec libvo_a ...
- boost之mutex scoped_lock
1.boost里的互斥量类型由mutex表示. 代码示例: #include <iostream> #include <string> #include <vector& ...
- 【BZOJ】【1863】【ZJOI2006】trouble 皇帝的烦恼
二分+DP Orz KuribohG 神题啊= = 满足单调性是比较显然的…… 然而蒟蒻并不会判断能否满足……QwQ 神一样的DP姿势:f[i]表示第 i 个与第1个最多有多少个相同,g[i]表示最少 ...
- 【POJ】【1637】Sightseeing tour
网络流/最大流 愚人节快乐XD 这题是给一个混合图(既有有向边又有无向边),让你判断是否有欧拉回路…… 我们知道如果一个[连通]图中每个节点都满足[入度=出度]那么就一定有欧拉回路…… 那么每条边都可 ...