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. python中静态方法(@staticmethod)和类方法(@classmethod)的区别

    一般来说,要使用某个类的方法,需要先实例化一个对象再调用方法. 而使用@staticmethod或@classmethod,就可以不需要实例化,直接类名.方法名()来调用. 这有利于组织代码,把某些应 ...

  2. Luogu3307:[SDOI2013]项链

    传送门 求每个珠子的方案数 即有序的求三元组 \((x,y,z),x,y,z\le a\) 满足 \(gcd(x,y,z)=1\) 设 \(G_i\) 表示 \(i\) 个小于等于 \(a\) 的有序 ...

  3. Dinic算法----最大流常用算法之一

    ——没有什么是一个BFS或一个DFS解决不了的:如果有,那就两个一起. 最大流的$EK$算法虽然简单,但时间复杂度是$O(nm^2)$,在竞赛中不太常用. 竞赛中常用的$Dinic$算法和$SAP$, ...

  4. 1142 奖学金 sort做法

    个人博客:doubleq.win 1142 奖学金 2007年NOIP全国联赛普及组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 白银 Silver 题解       题目 ...

  5. Android之NDK环境配置+JNI开发+so文件编译

    前言 这边Android作为日常记录,虽然破坏了文章队形~   最近人工智能挺火的,也稍微了解了一些库,比如关于视觉库openCV.要在安卓下调用这些C/C++库,需要用到JNI开发,在此把过程分享一 ...

  6. 微信小程序开发11-HTTPS网络通信(重点)

    1.OneNET平台支持https,将HTTP头部改成https://api.heclouds.com即可(重点!!!!!!!!) 2.如果我们需要从 https://test.com/getinfo ...

  7. js时间戳转换日期

    //js时间戳转换日期function formatDate(now) { var year=now.getFullYear(); var month=now.getMonth()+1; var da ...

  8. Python 解决写入csv中间隔一行空行问题

    转载解决写入csv中间隔一行空行问题 写入csv: with open(birth_weight_file,'w') as f: writer=csv.writer(f) writer.writero ...

  9. C# 按位或,按位与, 按位异或

    a != b  ----->  a = a | b  , a 或者 b 只要有一个为 1, 那么,a 的最终结果就为 1 a &= b  ----->  a = a & b ...

  10. Spring学习---Spring中利用组件实现从FTP服务器上传/下载文件

    FtpUtil.java import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundExcepti ...