Can a task specify dependency order

I feel like what I’m trying to do here is very basic, but I cannot seem to find documentation on the proper, gradle way to do this. Assuming the following tasks and dependency

task build
  task clean
  task compile
  build.dependsOn "compile"

How do I define a new task (rebuild) that first performs a clean and then performs build (and the dependent compile). Making rebuild dependent on clean and build does not guarantee that clean is run before build. Using .execute() is not supported I read, and more importantly does not run the dependent compile task.

In short, the answer is no - a task cannot currently specify a dependency order. More importantly, this feature wouldn’t solve the (general) ‘rebuild’ problem, which requires each project’s ‘clean’ task to get executed before any other task in the same project.

One solution is to check if ‘rebuild’ is in the list of explicitly specified task names, and if yes, add in ‘clean’ in the front of that list. That’s an approximation, but often good enough. The question is whether it’s enough of an improvement over ‘gradle clean build’ to justify a special solution limited to the ‘build’ task.