# How to run a task in the root project before compiling or running any of the subprojects?

**URL:** <https://discuss.gradle.org/t/how-to-run-a-task-in-the-root-project-before-compiling-or-running-any-of-the-subprojects/34739>\
**Category:** Help/Discuss\
**Created:** [January 30, 2020, 11:50am UTC](https://discuss.gradle.org/t/how-to-run-a-task-in-the-root-project-before-compiling-or-running-any-of-the-subprojects/34739 "2020-01-30T11:50:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kant111](https://avatars.discourse-cdn.com/v4/letter/k/4bbf92/32.png) [@kant111](https://discuss.gradle.org/u/kant111)\
**Post date:** [January 30, 2020, 11:50am UTC](https://discuss.gradle.org/t/how-to-run-a-task-in-the-root-project-before-compiling-or-running-any-of-the-subprojects/34739/1 "2020-01-30T11:50:58Z")

</div>

How to run a task in the root project before compiling or running any of the subprojects?

More specifically, I want to execute a proto(generate code from protocol buffers spec) task at the root project before even compiling any of the subprojects. How do I do that?

Any equivalent example would suffice as well.
