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

          Hide
          Paul King added a comment -

          All we need now is some doco?

          Show
          Paul King added a comment - All we need now is some doco?
          Hide
          Jim White added a comment -

          Yes indeed, Guillaume made a similar comment on the list about the base script abstract method stuff. I had just one more thing to do (PR #371 for GROOVY-6675) and I think this stuff all hangs together pretty well now. I assume there are at least a couple weeks before the the final release for 2.3.0?

          Show
          Jim White added a comment - Yes indeed, Guillaume made a similar comment on the list about the base script abstract method stuff. I had just one more thing to do (PR #371 for GROOVY-6675 ) and I think this stuff all hangs together pretty well now. I assume there are at least a couple weeks before the the final release for 2.3.0?
          Hide
          Guillaume Laforge added a comment -

          We will likely go straight to RC-mode, with an RC-1 already Thursday if all goes well (no big show-stopper, etc), so the sooner the better. The date for 2.3.0 final is not defined yet, but it could be 2-3 weeks maximum.

          Show
          Guillaume Laforge added a comment - We will likely go straight to RC-mode, with an RC-1 already Thursday if all goes well (no big show-stopper, etc), so the sooner the better. The date for 2.3.0 final is not defined yet, but it could be 2-3 weeks maximum.
          Hide
          Jim White added a comment -

          Well, I'll see what I can do but I'm pretty booked up and so next weekend is probably the earliest I can put much time into this again. As long as the code gets in on time the docs can get filled in easily enough.

          Show
          Jim White added a comment - Well, I'll see what I can do but I'm pretty booked up and so next weekend is probably the earliest I can put much time into this again. As long as the code gets in on time the docs can get filled in easily enough.
          Hide
          Guillaume Laforge added a comment -

          Ping on some documentation, Jim?

          Show
          Guillaume Laforge added a comment - Ping on some documentation, Jim?

            People

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

              Dates

              • Created:
                Updated:
                Resolved: