在 Gradle 中的任务排序中 mustRunAfter 和 shouldRunAfter 之间有什么区别? [英] What is the difference between mustRunAfter and shouldRunAfter in task ordering in Gradle?

查看:199
本文介绍了在 Gradle 中的任务排序中 mustRunAfter 和 shouldRunAfter 之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑在 gradle 中排序任务时应该使用 shouldRunAftermustRunAfter 中的哪一个.

I have this doubt as to when and which one out of shouldRunAfter and mustRunAfter should be used while ordering tasks in gradle.

推荐答案

都记录的很好,请看一下 此处.特别是:

It's all documented well, please have a look here. Especially:

当你使用must run after"排序规则时,你指定了 taskB必须始终在 taskA 之后运行,只要 taskA 和 taskB 都在跑.这表示为 taskB.mustRunAfter(taskA).应该运行after" 排序规则类似但不那么严格,因为它将被忽略在两种情况下.首先,如果使用该规则引入排序循环.其次当使用并行执行和所有依赖项时除了should run after"任务之外的任务已经被满足,那么这个任务将被运行,不管它的应该运行"之后"依赖项是否已运行.你应该使用应该运行after",其中的排序很有帮助,但并非严格要求.

When you use the "must run after" ordering rule you specify that taskB must always run after taskA, whenever both taskA and taskB will be run. This is expressed as taskB.mustRunAfter(taskA). The "should run after" ordering rule is similar but less strict as it will be ignored in two situations. Firstly if using that rule introduces an ordering cycle. Secondly when using parallel execution and all dependencies of a task have been satisfied apart from the "should run after" task, then this task will be run regardless of whether its "should run after" dependencies have been run or not. You should use "should run after" where the ordering is helpful but not strictly required.

编辑我还鼓励您阅读这个发布.

这篇关于在 Gradle 中的任务排序中 mustRunAfter 和 shouldRunAfter 之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆