Type: New Feature
Affects Version/s: None
Fix Version/s: 0.6
Sometimes, it's very useful for scripts to know their own directory; however,
determining the name of a script file in a portable way in Groovy is currently
royal pain in the neck. For details on Groovy's issues here, see:
For this & other reasons, I'd love it if Gradle would have some
extra 'build' object properties such as:
build.properties.buildScriptDirName == cannonicalized path to dir containing build.gradle file (or whatever it's named)
build.properties.buildScriptFileName == leaf-name of build script itself (typically build.gradle)
Eventually, I hope that Groovy's "script.name" property gets sorted out on all platforms
and is equal to the cannonicalized path to the script. However that's not quite good enough
for gradle for two reasons
 Often the directory is wanted, and "script.name" is the
fullpath to the script – not separating the name from the path.
Call me lazy, but I'd like my build environment to spare me
from hassles like this.
 The ugly-but-backward-compatible hack I came up with on Linux:
could end up giving you the path to a .gradle/cache directory, rather than
your build.gradle file's directory, depending if you've got caching on or not.
Madness! Thus this info really should be a built-in to gradle. I think that
'build.properties.<..some-name...>' is the logical place for it.
For more details on Groovy's current problems with script.name, see: