Uploaded image for project: 'Gradle'
  1. Gradle
  2. GRADLE-366

Gradle should make it easy to determine the full path to the build.gradle file

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.6

      Description

      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:
      http://jira.codehaus.org/browse/GROOVY-1642

      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

      [1] 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.

      [2] The ugly-but-backward-compatible hack I came up with on Linux:
      new File(getClass().protectionDomain.codeSource.location.path).parent
      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:
      http://jira.codehaus.org/browse/GROOVY-1642

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              hans_d Hans Dockter
              Reporter:
              jcox Jon Cox
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: