Understanding Gradle task dependency (dependsOn)

后端 未结 2 2120
醉梦人生
醉梦人生 2020-12-08 01:43

Two questions:

  1. What is the gradle way to specify that 1 task is comprised of several other tasks?
  2. It seems like gradle\'s taskName.execute()
2条回答
  •  -上瘾入骨i
    2020-12-08 02:44

    Gradle's task model is "flat" and doesn't have a concept of aggregation. (It's important to note that TaskInternal#execute is an internal method, and must not be called from build scripts.) Aggregation is often simulated with a lifecycle task (a task with task dependencies but without any task actions):

    task allTests {
        dependsOn tasks.withType(Test)
    }
    

    Besides dependsOn, the following task relationships are supported: mustRunAfter, shouldRunAfter, and finalizedBy.

提交回复
热议问题