gradle - 为什么Gradle在使用dependsOn时总是按字母顺序执行任务依赖
问题描述
无法理解为什么依赖任务在使用时按字母顺序执行dependsOn
。更让我困惑的是Gradle in Action一书 第 84 页In Gradle, the task execution order is not deterministic
上的声明。
后来作者继续说It’s important to understand that Gradle doesn’t guarantee the order in which the dependencies of a task are executed.
如果执行顺序是不确定的,那么顺序不应该总是按字母顺序排列,即它应该是随机的。
如果有人可以对此有所了解,那就太好了。查找有关 gradle 任务执行顺序的问题,但我的问题有点不同,因为我想知道为什么作者称执行顺序为非确定性的,为什么他甚至继续说没有保证的顺序,而实际上是什么我通过尝试几个例子看到是完全相反的(即总是按字母顺序排列)。
编辑 1 开始
我的 gradle 脚本(build.gradle):
version = '0.1-SNAPSHOT'
task first{
doLast{
println "first"
}
}
task second {
doLast{
println "second"
}
}
task fourth {
doLast{
println "fourth"
}
}
task wonder {
doLast{
println "Wonder"
}
}
task thunder {
doLast{
println "thunder"
}
}
task apple {
doLast{
println "apple"
}
}
task printVersion(dependsOn: [second, first, fourth, wonder, thunder, apple]) {
doLast{
logger.quiet "Version: $version"
}
}
task third{
doLast{
println "third"
}
}
third.dependsOn('printVersion')
以下是我每次尝试运行脚本时的顺序:
:apple SKIPPED
:first SKIPPED
:fourth SKIPPED
:second SKIPPED
:thunder SKIPPED
:wonder SKIPPED
:printVersion SKIPPED
:third SKIPPED
编辑 1 结束
解决方案
推荐阅读
- swift - 使用 Apples CryptoKit 在 iOS 和 Kotlin/Java 之间进行跨平台 AES 加密
- javascript - Stuck with Modal creation (Javascript and HTML)
- postgresql - Docker/PostgreSQL 使用 pgadmin4 创建服务器并遇到用户问题
- python - TypeError: list indices must be integers, not RowProxy
- scala - Iterate through a list of case class and just output a single case class
- scala - ScalaMock 难以模拟 HttpResponse
- java - After making a list of items in a string how do I have the selected item open a image pop up
- c - How do I assign values to or modify an extern struct declared in C header file?
- powershell - Powershell 参数分配失败
- nsmutableattributedstring - NSMutableAttributedString 使用 NSLinkAttributedName