groovy
  1. groovy
  2. GROOVY-3226

org.codehaus.groovy.tools.LoaderConfiguration fails to implement glob in expected fashion

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.5.7, 1.6-beta-2, 1.7-beta-1
    • Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows, Ubuntu, Groovy, Java
    • Number of attachments :
      0

      Description

      During startup, if the starter configuration file has a line:

      load !{ant.home}/lib/*.jar
      

      then all the jars in the directory

      {ant.home}/lib are added to the classpath of the root loader. However a line such as:
      
      

      load !{ant.home}

      /lib/ant*.jar

      
      

      results in no jars being added to the root loader classpath.

      The "globbing" implemented in org.codehaus.groovy.tools.LoaderConfiguration is violating the Rule of Least Surprise – in particular * is only being expanded if it is the first character of a path component. Either proper globbing shold be implemented or a switch to using regular expressions should be made.

      Globbing is clearly easier here for the user, but Java does not have a standard globbing sub-system, it only has support for regular expressions. Obvious directions:

      1. Extract the code from Ant that does the path globbing and just use it or a variation of it.
      2. Transform the glob expression into a regular expression and then use regular expressions in the Java code.
      3. Extend the current code to implement globbin so that it works in a more expected way.

      Given the string manipulation support in Java, 2 may be the best way forward.

        Activity

        Hide
        blackdrag blackdrag added a comment -

        fixed

        Show
        blackdrag blackdrag added a comment - fixed
        Hide
        Russel Winder added a comment -

        I wonder if the "fix" solves the problem of the "ant*.jar" above but fails to handle things like "flob*thing*.jar"?

        Show
        Russel Winder added a comment - I wonder if the "fix" solves the problem of the "ant*.jar" above but fails to handle things like "flob*thing*.jar"?
        Hide
        blackdrag blackdrag added a comment -

        I think that might work. I suggest you simply try it The "bug" was that in foo/ant*.jar the "foo/ant" was seen as parent directory, where it should have been "foo/" only. The stars itself are replaced by a regexp pattern... and we use replaceAll for this... so in theory it should do.

        Show
        blackdrag blackdrag added a comment - I think that might work. I suggest you simply try it The "bug" was that in foo/ant*.jar the "foo/ant" was seen as parent directory, where it should have been "foo/" only. The stars itself are replaced by a regexp pattern... and we use replaceAll for this... so in theory it should do.

          People

          • Assignee:
            blackdrag blackdrag
            Reporter:
            Russel Winder
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: