我尝试编写自己的Gradle任务:
task(incVersion) << {
[...]
}
task cleanDocBuild(dependsOn: ['clean','cleanDoc','incVersion','asciidoctor','war']) << {
cleanDoc.dependsOn clean
incVersion.dependsOn cleanDoc
asciidoctor.dependsOn incVersion
war.dependsOn asciidoctor
println 'Start Building...'
}
task(cleanDoc) << {
[...]
}
asciidoctor {
[...]
}
我想按特定顺序调用任务:
我该怎么做?
答案 0 :(得分:0)
您不仅要设置任务的dependsOn
属性(此属性不进行任何排序,只提供任务依赖性),还要设置mustRunAfter
或shouldRunAfter
,根据您的需求,使此任务按预定义顺序运行。您可以在official user guide中了解相关信息。在您的情况下,这可能类似于:
clenDoc.mustRunAfter clean
incVersion.mustRunAfter clenDoc
asciidoctor.mustRunAfter incVersion
war.mustRunAfter asciidoctor
cleanDocBuild.mustRunAfter war