def find_build_gradle(dir):
    """
    Recursively go up and find the nearest build.gradle file. Return the directory name
    of that build.gradle file.
    """
    build_gradle = dir.joinpath("build.gradle")
    if build_gradle.exists():
        return dir
    else:
        return find_build_gradle(dir.parent)