gradle doLast在执行之前执行

时间:2016-10-16 15:07:04

标签: gradle build.gradle

根据gradle文档,gradle按以下顺序执行任务:

配置 - > doFirst->动作 - > 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在最后两个动作之前执行,请帮助澄清。

提前致谢。

1 个答案:

答案 0 :(得分:0)

左移运算符(''.join(tupleVariable) )表示与<<相同。此外,我想澄清doLastdoFirst 行动。在doLast次操作之前执行doFirst次操作。