How to derive project directory path to a Gradle plugin?

Gradle v2.9 (Old, we’re upgrading soon)

I’m trying to create a Gradle plugin by following Writing Gradle Plugins. How can I have the plugin “derive” the project’s top directory, that is where build.gradle file is? if the plugin creates an hello task, I want it to do this

$ pwd
$ /some_path/project1
$ ls
build.gradle gradlew gradle src
$ ./gradlew hello
Hello /some_path/project1

project.rootDir and project.projectDir are what you are looking for