According to the documentation , the method getBuildDir() is deprecated and should be replaced with getLayout().getBuildDirectory().

The implementation of the deprecated method getBuildDir() is org.gradle.api.internal.project.DefaultProject#getBuildDir, and to be more explicit:

    @Deprecated
    public File getBuildDir() {
        return (File)this.getLayout().getBuildDirectory().getAsFile().get();
    }

Therefore, in order to remove the usage of the deprecated method and the warning, a solution is simply to apply the method's implementation directly in the code.