Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1642

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

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0
    • 2.3.0-beta-1
    • None
    • None

    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.

      Attachments

        Issue Links

          Activity

            People

              jimwhite James P. White
              mguillemot@yahoo.fr Marc Guillemot
              Votes:
              12 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: