groovy
  1. groovy
  2. GROOVY-3925

Multiple GrabResolvers with Grab don't seem to work, and GrabResolve can't be applied to imports

    Details

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

      Description

      Running the following code:

      @GrabResolver(name='jboss', root='http://repository.jboss.org/maven2')
      @GrabResolver(name='codehaus.snapshot', root='http://snapshots.repository.codehaus.org')
      @Grab(group='org.codehaus.gpars', module='gpars', version='0.9-beta-1')
      import groovyx.gpars.actor.PooledActorGroup
      
      println new PooledActorGroup()

      Gives the following error:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      /Users/tyates/Code/Groovy/chat/chatserver.groovy: 3: unable to resolve class groovyx.gpars.actor.PooledActorGroup
       @ line 3, column 1.
         @GrabResolver(name='jboss', root='http://repository.jboss.org/maven2')
         ^
      
      1 error

      If I move the GrabResolvers off to a different member, ie:

      @GrabResolver(name='jboss', root='http://repository.jboss.org/maven2')
      @GrabResolver(name='codehaus.snapshot', root='http://snapshots.repository.codehaus.org')
      def dummy() {}
      @Grab(group='org.codehaus.gpars', module='gpars', version='0.9-beta-1')
      import groovyx.gpars.actor.PooledActorGroup
      
      println new PooledActorGroup()

      Then the error changes to:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      /Users/tyates/Code/Groovy/chat/chatserver.groovy: 3: Cannot specify duplicate annotation on the same member : GrabResolver at line: 3 column: 1. File: /Users/tyates/Code/Groovy/chat/chatserver.groovy @ line 3, column 1.
         @GrabResolver(name='jboss', root='http://repository.jboss.org/maven2')
         ^
      
      1 error

      To get this to work, I need to do the following:

      @GrabResolver(name='jboss', root='http://repository.jboss.org/maven2')
      def dummy() {}
      @GrabResolver(name='codehaus.snapshot', root='http://snapshots.repository.codehaus.org')
      def dummy2() {}
      @Grab(group='org.codehaus.gpars', module='gpars', version='0.9-beta-1')
      import groovyx.gpars.actor.PooledActorGroup
      
      println new PooledActorGroup()

      which then gives the output:

      groovyx.gpars.actor.PooledActorGroup@2f2c55e4

      So it seems there may be two problems currently:

      1) You cannot specify multiple GrabResolvers for a single member
      2) You cannot specify GrabResolvers on import statements


      To check that 2 fails, I tried the following:

      @GrabResolver(name='restlet.org', root='http://maven.restlet.org')
      @Grab(group='org.restlet', module='org.restlet', version='1.1.6')
      import org.restlet.data.MediaType
      import org.restlet.resource.StringRepresentation
      
      println new StringRepresentation( "Hi", MediaType.TEXT_PLAIN )

        Issue Links

          Activity

          Hide
          Roshan Dawrani added a comment -

          If you are playing with the snapshot versions of the groovy in your talk, then I have done a fix on the trunk
          that allows multiple @GrabResolver (i.e, annotations not having retention policy as RUNTIME). I will be porting
          this fix to 1.7.x and 1.6.x in a bit.

          After the fix, point 1) from the JIRA is taken care of and the following works

          @GrabResolver(name='jboss', root='http://repository.jboss.org/maven2')
          @GrabResolver(name='codehaus.snapshot', root='http://snapshots.repository.codehaus.org')
          def dummy() {}
          @Grab(group='org.codehaus.gpars', module='gpars', version='0.9-beta-1')
          import groovyx.gpars.actor.PooledActorGroup
          
          println new PooledActorGroup()
          

          In fact, in the very first example of JIRA, if I re-order annotations a bit, then the following works too:

          @Grab(group='org.codehaus.gpars', module='gpars', version='0.9-beta-1')
          @GrabResolver(name='jboss', root='http://repository.jboss.org/maven2')
          @GrabResolver(name='codehaus.snapshot', root='http://snapshots.repository.codehaus.org')
          import groovyx.gpars.actor.PooledActorGroup
          
          println new PooledActorGroup()
          
          Show
          Roshan Dawrani added a comment - If you are playing with the snapshot versions of the groovy in your talk, then I have done a fix on the trunk that allows multiple @GrabResolver (i.e, annotations not having retention policy as RUNTIME). I will be porting this fix to 1.7.x and 1.6.x in a bit. After the fix, point 1) from the JIRA is taken care of and the following works @GrabResolver(name='jboss', root='http: //repository.jboss.org/maven2') @GrabResolver(name='codehaus.snapshot', root='http: //snapshots.repository.codehaus.org') def dummy() {} @Grab(group='org.codehaus.gpars', module='gpars', version='0.9-beta-1') import groovyx.gpars.actor.PooledActorGroup println new PooledActorGroup() In fact, in the very first example of JIRA, if I re-order annotations a bit, then the following works too: @Grab(group='org.codehaus.gpars', module='gpars', version='0.9-beta-1') @GrabResolver(name='jboss', root='http: //repository.jboss.org/maven2') @GrabResolver(name='codehaus.snapshot', root='http: //snapshots.repository.codehaus.org') import groovyx.gpars.actor.PooledActorGroup println new PooledActorGroup()
          Hide
          Roshan Dawrani added a comment -

          Regarding @GrabResolver also working on import statements, it seems more due to a compiler bug rather than a designed thing.

          The compiler lets even the following code compile:

          import groovy.beans.*
          
          @Bindable
          import org.codehaus.groovy.classgen.*
          
          class Test {}
          
          println Test
          

          where @Bindable is only supposed to be used on field/type targets and nothing else.

          Show
          Roshan Dawrani added a comment - Regarding @GrabResolver also working on import statements, it seems more due to a compiler bug rather than a designed thing. The compiler lets even the following code compile: import groovy.beans.* @Bindable import org.codehaus.groovy.classgen.* class Test {} println Test where @Bindable is only supposed to be used on field/type targets and nothing else.
          Hide
          Paul King added a comment -

          Fixed in trunk

          Show
          Paul King added a comment - Fixed in trunk
          Hide
          Paul King added a comment -

          Also applied to 1_7_X branch. Both of these should work now:

          @GrabResolver(name='jboss', root='http://repository.jboss.org/maven2')
          @GrabResolver(name='codehaus.snapshot', root='http://snapshots.repository.codehaus.org')
          @Grab('org.codehaus.gpars:gpars:0.9-beta-1')
          import groovyx.gpars.actor.*
          assert Actors.name.contains('groovyx')
          

          and this:

          @Grapes([
            @GrabResolver(name='jboss', root='http://repository.jboss.org/maven2'),
            @GrabResolver(name='codehaus.snapshot', root='http://snapshots.repository.codehaus.org'),
            @Grab('org.codehaus.gpars:gpars:0.9-beta-1')
          ])
          import groovyx.gpars.actor.*
          assert Actors.name.contains('groovyx')
          
          Show
          Paul King added a comment - Also applied to 1_7_X branch. Both of these should work now: @GrabResolver(name='jboss', root='http: //repository.jboss.org/maven2') @GrabResolver(name='codehaus.snapshot', root='http: //snapshots.repository.codehaus.org') @Grab('org.codehaus.gpars:gpars:0.9-beta-1') import groovyx.gpars.actor.* assert Actors.name.contains('groovyx') and this: @Grapes([ @GrabResolver(name='jboss', root='http: //repository.jboss.org/maven2'), @GrabResolver(name='codehaus.snapshot', root='http: //snapshots.repository.codehaus.org'), @Grab('org.codehaus.gpars:gpars:0.9-beta-1') ]) import groovyx.gpars.actor.* assert Actors.name.contains('groovyx')
          Hide
          Paul King added a comment - - edited

          Now also in 1.7-rc2

          Show
          Paul King added a comment - - edited Now also in 1.7-rc2

            People

            • Assignee:
              Paul King
              Reporter:
              Tim Yates
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: