在自定义任务中执行gradle构建任务 [英] Executing gradle build tasks in custom tasks
本文介绍了在自定义任务中执行gradle构建任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任务 在gradle中有一个自定义任务调用了release,我希望这个任务执行clean和build任务:发布
{
//做某事
clean
build
}
我知道可以从命令行调用任务,如
gradle build release
但是我想知道天气是否可以在自定义任务中执行构建任务?
$ b $<$>您可以简单地使用'finalizedBy'特性,或者在'release'任务中配置它: p $ p>
任务发布
{
finalizedBy clean,build
//做一些事情
}
或者在'release'任务后配置它:
release.finalizedBy clean,build
请注意此功能目前正在孵化,未来可能会发生变化。
I have a custom task in gradle Called release and I want this task to execute the clean and build tasks:
task release
{
//do something
clean
build
}
I know it is possible to call tasks from command line like
gradle build release
But I want to know weather it is possible to execute build tasks within custom tasks?
解决方案
You can simply use 'finalizedBy' feature either by configure it inside 'release' task:
task release
{
finalizedBy clean, build
// Do some stuff
}
or configure it after 'release' task:
release.finalizedBy clean, build
Note that this feature is currently in incubation and may change in the future.
这篇关于在自定义任务中执行gradle构建任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文