Gradle Goodness: Check Task Dependencies With a Dry Run

We can run a Gradle build without any of the task actions being executed. This is a so-called dry run of our build. We can use the dry run of a build to see if the task dependencies we have defined or are defined in a plugin are defined properly. Because all tasks and task dependencies are resolved if we use the dry run mode we can see in the output which tasks are executed.

We define a simple build file with three tasks and some task dependencies:

view sourceprint?

0.def printTaskNameAction = {

1.println "Running ${it.name}"

2.}

3.

4.task first << printTaskNameAction

5.

6.task second(dependsOn: first) << printTaskNameAction

7.

8.task third(dependsOn: [first, second]) << printTaskNameAction

To run a Gradle build as a dry run we can use the command line option -m or --dry-run. So let‘s execute the task third with the dry run command line option:

$ gradle -m third

:first SKIPPED

:second SKIPPED

:third SKIPPED

BUILD SUCCESSFUL

Total time: 2.242 secs

$

And we see in the output none of the tasks are really executed, because SKIPPED is shown, but we do see the task names of the tasks that are resolved.

Written with Gradle 2.2.

时间: 2024-10-08 20:55:16

Gradle Goodness: Check Task Dependencies With a Dry Run的相关文章

Gradle Goodness: Skip Building Project Dependencies

If we use Gradle in a multi-module project we can define project dependencies between modules. Gradle uses the information from the project dependencies to determine which tasks need to be run. For example if module B depends on module A and we want

Gradle Goodness: Working with Live Task Collection

Gradle support the definition of so called live collections. These collections are mostly created based on criteria like with a filter() or matching() method. The collection content can change if the content of the source collection changes. For exam

Gradle Goodness: Task Output Annotations Create Directory Automatically

Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of Gradle is incremental build support. With incremental build support a task is only executed if it is really necessary. For example if a task generate

Gradle Goodness: Copy Files with Filtering

Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filtering capabilities. This means we can change the contents of the files that are copied before they reach their new destination. We use the filter() method

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. One of the ways to alter the build configuration is with initialization or init scripts. These are like other Gradle scripts but are executed before t

Gradle Goodness: Automatic Clean Tasks

Gradle adds the task rule clean<Taskname> to our projects when we apply the base plugin. This task is able to remove any output files or directories we have defined for our task. For example we can assign an output file or directory to our task with

Gradle Goodness: Changing Name of Default Build File

Gradle uses the name build.gradle as the default name for a build file. If we write our build code in a file build.gradle then we don't have to specify the build filename when we run tasks. We can create build files with a different name other than b

Gradle之Android Gradle Plugin 主要 Task 分析(三)

[Android 修炼手册]Gradle 篇 -- Android Gradle Plugin 主要 Task 分析 预备知识 理解 gradle 的基本开发 了解 gradle task 和 plugin 使用及开发 了解 android gradle plugin 的使用 看完本文可以达到什么程度 了解 android gradle plugin 中各个 task 作用 了解 android gradle plugin 中主要 task 的实现 阅读前准备工作 1.项目添加 android

make输出log以及dry run

一.输出log 如何获得Linux下make的log? 如何保存控制台对话? 如何将编译过程的信息保存成日志? 编译的过程可能会出错,导致编译过程无法继续进行.详细分析出错信息,有助于解决源码中的语法错误. 那么如何保存配置编译过程的信息?这些信息量很大,都可能超出Shell向上翻滚查看的范围.最好是把编译过程的信息保存成日志文件,方便后面的分析. 举例说明保存编译信息的行命令,它把make过程打印的所有信息都保存在xxx.log中. $make 2>&1|tee xxx.log 这条命令是