Execute Custom Task in Root Project

How do I reference/use the ‘preBuild’ property? I am trying to execute a custom task, that verifies that all sub-projects have a populated description. The custom task shall be executed for any build execution. As I am executing a multi-module project, I saw people referencing the following code:


This, however, gives me:

‘Could not find property ‘preBuild’ on root project…’

As a work-around, I am doing:

‘tasks[‘checkProjectDescriptions’].execute()’ as the last statement in ‘build.gradle’. But this does not look very clean. So I am wondering is there something that I am missing or should do rather instead?

Thanks a million!

Where are you seeing people referencing this? Prebuild isn’t a lifecycle task that’s added by any of the core Gradle plugins.