根据gradle文档,gradle按照以下顺序执行任务:
配置-> doFirst-> Action -> doLast。
这是我的build.gradle:
task hello << {
println "${hello.message}"
}
hello << {
println "${hello.message} 2"
}
configure(hello, {
ext.message = 'hello'
description = "Hello task declared in project '${project.name}'"
doFirst {
println 'hello do first'
}
doLast {
println 'hello do last'
}
})
hello << {
println "${hello.message} 3"
}
hello << {
println "${hello.message} 4"
}
该任务的输出为:
:hello
hello do first
hello
hello 2
hello do last
hello 3
hello 4
BUILD SUCCESSFUL
Total time: 0.83 secs
doLast在最后两个操作之前执行,请帮助进行说明。
提前致谢。
最佳答案
左移运算符(<<
)的含义与doLast
相同。另外,我想澄清doFirst
和doLast
是 Action 。 doFirst
操作先于doLast
操作执行。
关于gradle - gradle doLast在 Action 之前执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40071782/