Details
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
- relates to
-
GROOVY-3930
groovyc does not allow multiple annotations of the same type even if Retention Policy is SOURCE
-
Disallowing duplicate annotations of the same type on one element was done under
GROOVY-3852,because when done, JVM starts having AnnotationFormatError issues at runtime when annotations
are accessed.
Some links about JVM not handling multiple annotations of the same type on same element:
1)http://stackoverflow.com/questions/1554112/multiple-annotations-of-the-same-type-on-one-element
2)http://www.docjar.com/html/api/sun/reflect/annotation/AnnotationParser.java.html
If multiple GrabResolver make sense, then what is needed is a new annotation @GrabResolvers
that can handle multiple GrabResolver entries.