In Gradle we can create dependencies between tasks. But we can also exclude certain tasks from those dependencies. We use the command-line option -x or --exclude-task and specify the name of task we don't want to execute. Any dependencies of this task are also excluded from execution. Unless another task depends on the same task and is executed. Let's see how this works with an example:

00.task copySources << {
01.println 'Copy sources.'
02.}
03. 
04.task copyResources(dependsOn: copySources) << {
05.println 'Copy resources.'
06.}
07. 
08.task jar(dependsOn: [copySources, copyResources]) << {
09.println 'Create JAR.'
10.}
11. 
12.task deploy(dependsOn: [copySources, jar]) << {
13.println 'Deploy it.'
14.}

We execute the deploy task:

$ gradle -q deploy
Copy sources.
Copy resources.
Create JAR.
Deploy it.

Now we exclude the jar task. Notice how the copySources task is still executed because of the dependency in the deploy task:

$ gradle -q deploy -x jar
Copy sources.
Deploy it.

Gradle Goodness: Excluding Tasks for Execution的更多相关文章

  1. Gradle Goodness: Adding Tasks to a Predefined Group

    In Gradle we can group related tasks using the group property of a task. We provide the name of our ...

  2. 打包APK出现org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:lintVitalRelease'.

    AndroidS Studio打包APK时出现问题:org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':a ...

  3. Gradle Goodness: Task Output Annotations Create Directory Automatically

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

  4. 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. ...

  5. org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection

    转载请注明出处:http://www.cnblogs.com/cnwutianhao/p/6709758.html Android Studio导入项目报错: org.gradle.api.inter ...

  6. Android studio Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to

    http://blog.csdn.net/FlyRabbit_1/article/details/74536317 Error:org.gradle.api.internal.tasks.Defaul ...

  7. Gradle Goodness: Copy Files with Filtering

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

  8. 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 f ...

  9. 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 ...

随机推荐

  1. 【MySQL数据库】一些bug的解决

    往往碰到mysql配置好后,第二天就登不上,也运行不了服务. 在cmd中输入 net start mysql  报mysql无法启动系统错误1067等 解决方案: 以前搞到最后没办法,重装了,后来找到 ...

  2. AIX 6.1记录

    安装Oracle需要开启远程桌面进行访问 1. X Windows需要如下软件包才能正常运行 lslpp -l X11.apps.rte X11.apps.xterm X11.base.rte X11 ...

  3. JDBC中处理事务,小Demo

    事务的四大特性(ACID):  原子性(Atomicity):事务中所有操作是不可再分割的原子单位.事务中所有操作要么全部执行成功,要么全部执行失败.  一致性(Consistency):事务执行 ...

  4. MvcForum作者称该项目进入缓慢更新

    MvcForum作者在github上发表 This project is no longer actively developed as I don't have the time. As and w ...

  5. Android adb命令查看sharedpreferences

    adb shell run-as com.example.android //对应包名 ls查看当前目录下的所有文件,找到shared_prefs cd shared_prefs ls 查看所有的 s ...

  6. python 待关注库

    Python待关注库 GUI 图形 Tkinter/wxPython/PyGTK/PyQt/PySide Web框架 django/web2py/flask/bottle/tornadoweb/web ...

  7. oralce的判断语句

    大家对 IF ELSE 语句应该都很熟悉吧,它是用来对过程进行控制的.在 SQL 的世界中 CASE 语句有类似的效果.下面简单的介绍 CASE 语句的用法. CASE 语句的形式 事实上,CASE ...

  8. 从golang-gin-realworld-example-app项目学写httpapi (一)

    https://wangzitian0.github.io/2013/06/29/zero-to-one-1/ https://github.com/gothinkster/golang-gin-re ...

  9. awk单行脚本快速参考

    AWK单行脚本快速参考 2008年4月28日编辑: Eric Pement eric [at] pement.org 版本 0.26翻译: 董一粟 yisudong [at] gmail.com 最新 ...

  10. 为什么TCP协议终止链接要四次?

    为什么TCP协议终止链接要四次? 1.当主机A确认发送完数据且知道B已经接受完了,想要关闭发送数据口(当然确认信号还是可以发),就会发FIN给主机B. 2.主机B收到A发送的FIN,表示收到了,就会发 ...