问题
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 wether it is possible to execute build tasks within custom tasks?
回答1:
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.
来源:https://stackoverflow.com/questions/38751650/executing-gradle-build-tasks-in-custom-tasks