前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【Android Gradle 插件】自定义 Gradle 任务 ⑦ ( 控制 Gradle 执行任务顺序 | Task#dependsOn 函数 | Task#mustRunAfter 函数 )

【Android Gradle 插件】自定义 Gradle 任务 ⑦ ( 控制 Gradle 执行任务顺序 | Task#dependsOn 函数 | Task#mustRunAfter 函数 )

作者头像
韩曙亮
发布2023-03-30 17:06:36
6150
发布2023-03-30 17:06:36
举报
文章被收录于专栏:韩曙亮的移动开发专栏

文章目录

Android Plugin DSL Reference 参考文档 :

一、Task#dependsOn 函数


Task#dependsOn 函数的作用是为 Gradle 任务设置依赖任务 , 执行该任务前 , 依赖任务必须被满足 ;

代码语言:javascript
复制
Task dependsOn​(Object... paths)

Adds the given dependencies to this task. 
See here for a description of the types of objects which can be used as task dependencies.
将给定的依赖项添加到此任务。
有关可用作任务依赖项的对象类型的描述,请参阅此处。

Parameters:
paths - The dependencies to add to this task.
        要添加到此任务的依赖项。
Returns:
the task object this method is applied to
应用此方法的任务对象

文档地址 : https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html#dependsOn-java.lang.Object…-

二、Task#mustRunAfter 函数


Task#mustRunAfter 函数的作用是为 Gradle 任务设置该任务执行时 , 必须在某个任务之后 ;

代码语言:javascript
复制
Task mustRunAfter​(Object... paths)
Specifies that this task must run after all of the supplied tasks.
指定此任务必须在所有提供的任务之后运行。

 task taskY {
     mustRunAfter "taskX"
 }
 
For each supplied task, this action adds a task 'ordering', 
and does not specify a 'dependency' between the tasks. 
As such, it is still possible to execute 'taskY' without first executing the 'taskX' in the example.
对于每个提供的任务,此操作添加一个任务“排序”,
并且不指定任务之间的“依赖关系”。
因此,仍然可以在不首先执行示例中的“taskX”的情况下执行“taskY”。

See here for a description of the types of objects which can be used to specify an ordering relationship.
有关可用于指定排序关系的对象类型的描述,请参阅此处。

Parameters:
paths - The dependencies to add to this task.
        要添加到此任务的依赖项。
Returns:
the task object this method is applied to
应用此方法的任务对象

文档地址 : https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html#mustRunAfter-java.lang.Object…-

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-09-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文章目录
  • 一、Task#dependsOn 函数
  • 二、Task#mustRunAfter 函数
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档