我目前正在编写gradle脚本来自动化一些构建。但是,似乎有两种创建任务的方法。我该怎么办?为什么要放在第一位呢?
task copy(type: Copy, group: "Custom", description: "Copies sources to the dest directory") {
from "src"
into "dest"
}
vs
tasks.register("gutenTag", Greeting) {
group = 'Welcome'
description = 'Produces a German greeting'
message = 'Guten Tag'
recipient = 'Welt'
}
答案 0 :(得分:2)
第一种是将任务添加到构建中的(一种)较旧的方法
第二个是使用寄存器,它可以避免任务配置
https://docs.gradle.org/current/userguide/task_configuration_avoidance.html
那是;仅在构建中使用任务时才配置任务