How to replace buildDir?

Now I’m setting the path to build.gradle as follows

android {
    buildDir = $path$
    ...
}

But Android Studio talks about obsolescence and this is indicated here.
What is the recommended method now?

Having it inside android { ... } actually is weird and just visual clutter if the android extension does not have a buildDir property, but you are setting the one on project.

Anyway, the link you added exactly tells you the replacement, and even the JavaDoc of buildDir tells you.