我对gradle比较陌生。为了在集群上创建自动部署脚本,我创建了一堆相互依赖的自定义任务。例如:
class StartSchedulerTask extends SchedulerTask {
@TaskAction
void start() {
dependsOn env.nodes.name.collect {"startTomcat_$it"}
println "Starting quartz on node: ${node}"
}
}
在 build.gradle 中,我动态创建了任务:
project.extensions.environment.nodes.each { TomcatNode n ->
String name = n.name
task "nodeInit_$name"(type: DeployToNodeInitTask) {
node(n)
}
task "stopWorker_$name"(type: StopWorkerTask) {
node(n)
}
task "stopTomcat_$name"(type: StopTomcatTask){
node(n)
}
task "updateAppConfigs_$name"(type: UpdateAppConfigsTask){
node(n)
apps(V3Application.ALL_APPS)
buildName('develop')
}
task "deployWars_$name"(type: DeployWarsTask){
node(n)
apps(V3Application.ALL_APPS)
buildName('develop')
}
task "startTomcat_$name"(type: StartTomcatTask){
node(n)
}
task "startWorker_$name"(type: StartWorkerTask){
node(n)
}
task "terminateNode_$name"(type: DeployToNodeTerminationTask){
node(n)
}
}
task stopScheduler(type: StopSchedulerTask) {
environment(environment)
}
task startScheduler(type: StartSchedulerTask) {
environment(environment)
}
默认任务配置为 startScheduler,这是部署过程的最后一步,其想法是任务图一旦构建,将负责我的任务的正确执行顺序。
但是,当我打印出任务图时,列出的唯一任务是 startScheduler。我错过了什么吗?