[ 
https://issues.apache.org/jira/browse/GROOVY-8860?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16666603#comment-16666603
 ] 

Paul King commented on GROOVY-8860:
-----------------------------------

You could get the same behavior with earlier versions of Spock but it was less 
common when using for instance groovyConsole since the console didn't use the 
all jar but Spock had the all jar as it's dependency. The all jar in Groovy 
2.5+ has been phased out due to JDK9+ modules (JPMS). So Spock now depends on 
several jars and the error will be more common.

As an alternative to @GrabExclude, you can try this:
{code}
@Grab('org.spockframework:spock-core:1.2-groovy-2.5;transitive=false')
class TestX extends spock.lang.Specification {
   def 'test method'() {
       expect:
       1 + 1 == 2
   }
}
{code}

> Use of @Grab to get spock-core library v1.2 for groovy v2.5 causes an 
> exception
> -------------------------------------------------------------------------------
>
>                 Key: GROOVY-8860
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8860
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.5.3
>         Environment: openjdk version "1.8.0_181"
> OpenJDK Runtime Environment (Zulu 8.31.0.1-macosx) (build 1.8.0_181-b02)
> OpenJDK 64-Bit Server VM (Zulu 8.31.0.1-macosx) (build 25.181-b02, mixed mode)
> Groovy Version: 2.5.3 JVM: 1.8.0_181 Vendor: Azul Systems, Inc. OS: Mac OS X
> Mac 10.13.6 (Darwin Kernel Version 17.7.0)
>            Reporter: Venkatesh-Prasad Ranganath
>            Priority: Major
>
> The use of @Grapes/@Grab to get spock-core libraries v1.2 for Groovy v2.5 
> causes an exception due to version mismatch of groovy-nio module.
>  
> Execute the following script with groovy:
> {code}
> @Grab('org.spockframework:spock-core:1.2-groovy-2.5')
> class TestX extends spock.lang.Specification {
>    def 'test method'() {
>    }
> }
> {code}
> 2. Observe the following output:
> {{org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:}}
>  \{{ General error during conversion: Conflicting module versions. Module 
> [groovy-nio is loaded in version 2.5.3 and you are trying to load version 
> 2.5.2}}{{groovy.lang.GroovyRuntimeException: Conflicting module versions. 
> Module [groovy-nio is loaded in version 2.5.3 and you are trying to load 
> version 2.5.2}}
>  \{{     at 
> org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl$DefaultModuleListener.onModule(MetaClassRegistryImpl.java:523)}}
>  \{{     at 
> org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromProperties(ExtensionModuleScanner.java:87)}}
>  \{{     at 
> org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerExtensionModuleFromProperties(MetaClassRegistryImpl.java:169)}}
>  \{{     at 
> groovy.grape.GrapeIvy.processCategoryMethods(GrapeIvy.groovy:342)}}
>  \{{     at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:285)}}
>  \{{     at groovy.grape.Grape.grab(Grape.java:165)}}
>  \{{     at 
> groovy.grape.GrabAnnotationTransformation.visit(GrabAnnotationTransformation.java:376)}}
>  \{{     at 
> org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:320)}}
>  \{{     at 
> org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:976)}}
>  \{{     at 
> org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:651)}}
>  \{{     at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:627)}}
>  \{{     at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:604)}}
>  \{{     at 
> groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:354)}}
>  \{{     at 
> groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:87)}}
>  \{{     at 
> groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:323)}}
>  \{{     at 
> groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:320)}}
>  \{{     at 
> org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:147)}}
>  \{{     at 
> groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:318)}}
>  \{{     at groovy.lang.GroovyShell.parseClass(GroovyShell.java:543)}}
>  \{{     at groovy.lang.GroovyShell.run(GroovyShell.java:372)}}
>  \{{     at groovy.lang.GroovyShell.run(GroovyShell.java:362)}}
>  \{{     at groovy.ui.GroovyMain.processOnce(GroovyMain.java:588)}}
>  \{{     at groovy.ui.GroovyMain.run(GroovyMain.java:332)}}
>  \{{     at groovy.ui.GroovyMain.access$1400(GroovyMain.java:69)}}
>  \{{     at groovy.ui.GroovyMain$GroovyCommand.process(GroovyMain.java:291)}}
>  \{{     at groovy.ui.GroovyMain.processArgs(GroovyMain.java:134)}}
>  \{{     at groovy.ui.GroovyMain.main(GroovyMain.java:116)}}
>  \{{     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)}}
>  \{{     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)}}
>  \{{     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)}}
>  \{{     at java.lang.reflect.Method.invoke(Method.java:498)}}
>  \{{     at 
> org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:110)}}
>  \{{     at 
> org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)}}
> {{1 error}}
>  
> Since I am not sure if this is a Groovy or Spock issue, I have reported the 
> same issue to Spock ([https://github.com/spockframework/spock/issues/943])



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to