groovy
  1. groovy
  2. GROOVY-1642

Script needs to be able to retrieve the full path of "its" file

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 2.3.0-beta-1
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Problem previously described on the mailing list: http://www.nabble.com/Script%3A-get-file-path-name-of-executing-script-tf2950940.html#a8253010

      It's a common need when using scripts to make some operations on the file system to get the name of the file containing the script beeing executed. The Script class doesn't provide this information currently but it seems possible to retrieve it with:

      URL scriptUrl = getClass().classLoader.resourceLoader.loadGroovySource(getClass().name)

      According to Jochen this may work... but not all the time.

      What we would need is a safe way (as property of Script) to access this information like Ruby/Perls _FILE_ const.

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Jim White
              Reporter:
              Marc Guillemot
            • Votes:
              12 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: