官术网_书友最值得收藏!

Executing multiple tasks

With just a simple build script, we already discussed that we have a couple of default tasks besides our own task that we can execute. To execute multiple tasks, we only have to add each task name to the command line. Let's execute our helloWorld custom task and built-in tasks task:

$ gradle helloWorld tasks
:helloWorld
Hello world.
:tasks
------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------
Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]
Help tasks
----------
 components - Displays the components produced by root project 'hello-world'. [incubating]
 dependencies - Displays all dependencies declared in root project 'hello-world'.
dependencyInsight - Displays the insight into a specific dependency in root project 'hello-world'.
help - Displays a help message.
model - Displays the configuration model of root project 'hello-world'. [incubating]
projects - Displays the sub-projects of root project 'hello-world'.
properties - Displays the properties of root project 'hello-world'.
tasks - Displays the tasks runnable from root project 'hello-world'.
Other tasks
-----------
helloWorld
To see all tasks and more detail, run gradle tasks --all
To see more detail about a task, run gradle help --task <task>
BUILD SUCCESSFUL
Total time: 2.028 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.12/userguide/gradle_daemon.html

We see the output of both tasks. First, helloWorld is executed, followed by tasks. In the output, we see the task names prepended  with a colon (:) and the output is in the next lines.

Gradle executes the tasks in the same order as they are defined in the command line. Gradle will only execute a task once during the build. So even if we define the same task multiple times, it will only be executed once. This rule also applies when tasks have dependencies on other tasks. Gradle will optimize the task execution for us and we don't have to worry about that.

主站蜘蛛池模板: 泗水县| 蚌埠市| 襄城县| 清原| 颍上县| 商丘市| 秭归县| 曲松县| 通榆县| 壶关县| 阿鲁科尔沁旗| 宁南县| 湄潭县| 六安市| 武川县| 永川市| 孝感市| 东光县| 荣昌县| 东乌珠穆沁旗| 柳林县| 儋州市| 普兰店市| 砚山县| 孝义市| 襄城县| 开阳县| 酉阳| 阜康市| 建始县| 塘沽区| 南安市| 六盘水市| 漾濞| 乌鲁木齐县| 上虞市| 雅安市| 长宁县| 宁南县| 禄劝| 张家口市|