There are several ways to accomplish this.
- If you look at the Working With Files page, you can simply use the
file()
method that is a part of theProject
object. - If you look at the Project DSL Docs, you should see the
projectDir
property. Thes properties are available throughout thebuild.gradle
script.
They can be used, respectively, like this:
task myTask << {
println file('.')
println projectDir
}
Would output
/full/path/to/your/project/ /full/path/to/your/project/
Where that directory contains the build.gradle
file where the task is located.