groovy
  1. groovy
  2. GROOVY-3730

Provide more control for @Grapes to exclude transitives or adjust classloader

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7-beta-1
    • Fix Version/s: 1.7-beta-2
    • Component/s: Grape
    • Labels:
      None
    • Number of attachments :
      1

      Description

      The current @Grab and @Grapes annotations provide a simplified way to bring in dependencies but there are some limitations:

      • you get all transitive dependencies
      • there is no way to exclude a particular unwanted transitive dependency
      • you sometimes don't get the right classloader

      We should consider enhancing support to overcome these limitations.

        Issue Links

          Activity

          Hide
          blackdrag blackdrag added a comment -

          (1) here I am refering to the fact that you provide up to two class loader for the compiler. The separation is not exactly new, but wasn't done so strictly in the past. But now we seperated that much more, because transforms need a different path potentially. running Groovy from the command line means of course that it is the same class loader, or at last has the same ancestor.

          (2) "don't use that flag"... does it mean it is on or off by default? If it is off by default it is ok for me.

          (3) If you use Grab.grab() it is up to the user to use the correct loader I would say. I am thinking about the annotation, where the user has not this control.

          Show
          blackdrag blackdrag added a comment - (1) here I am refering to the fact that you provide up to two class loader for the compiler. The separation is not exactly new, but wasn't done so strictly in the past. But now we seperated that much more, because transforms need a different path potentially. running Groovy from the command line means of course that it is the same class loader, or at last has the same ancestor. (2) "don't use that flag"... does it mean it is on or off by default? If it is off by default it is ok for me. (3) If you use Grab.grab() it is up to the user to use the correct loader I would say. I am thinking about the annotation, where the user has not this control.
          Hide
          Paul King added a comment -

          Added to trunk after further discussions. Could do with some more tests but that might have to wait.

          Show
          Paul King added a comment - Added to trunk after further discussions. Could do with some more tests but that might have to wait.
          Hide
          John Hurst added a comment -

          Hmm. As I said in my comment above, I couldn't get @GrabExclude() to work.

          Does it work for you?

          Here's what I'm trying now, with Groovy trunk:

          @Grapes([
            @Grab("org.apache.poi#poi;3.5-beta5"),
            @GrabExclude("logkit#logkit"),
            @GrabExclude("avalon-framework#avalon-framework")
          ])
          void foo() {
          }
          

          with this result:

          [jhurst@zappa Desktop]$groovy --version
          Groovy Version: 1.7-beta-2-SNAPSHOT JVM: 1.6.0_14
          [jhurst@zappa Desktop]$rm -rf ~/.groovy/grapes/*
          [jhurst@zappa Desktop]$rm -rf ~/.ivy2/cache/*
          [jhurst@zappa Desktop]$groovy TryGrapes.groovy 
          org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          /home/jhurst/Desktop/TryGrapes.groovy: 4: 'version'is not part of the annotation groovy.lang.GrabExclude -> groovy.lang.GrabExclude in @groovy.lang.GrabExclude
           @ line 4, column 3.
               @GrabExclude("logkit#logkit"),
               ^
          
          /home/jhurst/Desktop/TryGrapes.groovy: -1: Unexpected type java.lang.Object in @groovy.lang.GrabExclude
           @ line -1, column -1.
          /home/jhurst/Desktop/TryGrapes.groovy: 5: 'version'is not part of the annotation groovy.lang.GrabExclude -> groovy.lang.GrabExclude in @groovy.lang.GrabExclude
           @ line 5, column 3.
               @GrabExclude("avalon-framework#avalon-framework")
               ^
          
          /home/jhurst/Desktop/TryGrapes.groovy: -1: Unexpected type java.lang.Object in @groovy.lang.GrabExclude
           @ line -1, column -1.
          4 errors
          

          I'm not clear on whether @GrabExclude is supposed to be working.

          Show
          John Hurst added a comment - Hmm. As I said in my comment above, I couldn't get @GrabExclude() to work. Does it work for you? Here's what I'm trying now, with Groovy trunk: @Grapes([ @Grab( "org.apache.poi#poi;3.5-beta5" ), @GrabExclude( "logkit#logkit" ), @GrabExclude( "avalon-framework#avalon-framework" ) ]) void foo() { } with this result: [jhurst@zappa Desktop]$groovy --version Groovy Version: 1.7-beta-2-SNAPSHOT JVM: 1.6.0_14 [jhurst@zappa Desktop]$rm -rf ~/.groovy/grapes/* [jhurst@zappa Desktop]$rm -rf ~/.ivy2/cache/* [jhurst@zappa Desktop]$groovy TryGrapes.groovy org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: /home/jhurst/Desktop/TryGrapes.groovy: 4: 'version'is not part of the annotation groovy.lang.GrabExclude -> groovy.lang.GrabExclude in @groovy.lang.GrabExclude @ line 4, column 3. @GrabExclude( "logkit#logkit" ), ^ /home/jhurst/Desktop/TryGrapes.groovy: -1: Unexpected type java.lang. Object in @groovy.lang.GrabExclude @ line -1, column -1. /home/jhurst/Desktop/TryGrapes.groovy: 5: 'version'is not part of the annotation groovy.lang.GrabExclude -> groovy.lang.GrabExclude in @groovy.lang.GrabExclude @ line 5, column 3. @GrabExclude( "avalon-framework#avalon-framework" ) ^ /home/jhurst/Desktop/TryGrapes.groovy: -1: Unexpected type java.lang. Object in @groovy.lang.GrabExclude @ line -1, column -1. 4 errors I'm not clear on whether @GrabExclude is supposed to be working.
          Hide
          Paul King added a comment - - edited

          My bad, can you try again now (with trunk). The example below should work for example:

          @Grapes([
            @Grab("org.apache.poi#poi;3.5-beta6"),
            @GrabExclude("logkit:logkit"),
            @GrabExclude("avalon-framework#avalon-framework")
          ])
          import org.apache.poi.hssf.util.CellReference
          assert new CellReference(0, 0, false, false).formatAsString() == 'A1'
          assert new CellReference(1, 3).formatAsString() == '$D$2'
          
          Show
          Paul King added a comment - - edited My bad, can you try again now (with trunk). The example below should work for example: @Grapes([ @Grab( "org.apache.poi#poi;3.5-beta6" ), @GrabExclude( "logkit:logkit" ), @GrabExclude( "avalon-framework#avalon-framework" ) ]) import org.apache.poi.hssf.util.CellReference assert new CellReference(0, 0, false , false ).formatAsString() == 'A1' assert new CellReference(1, 3).formatAsString() == '$D$2'
          Hide
          John Hurst added a comment -

          Thanks Paul, that's working now.

          I like this mechanism!

          JH

          Show
          John Hurst added a comment - Thanks Paul, that's working now. I like this mechanism! JH

            People

            • Assignee:
              Paul King
              Reporter:
              Paul King
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: