How to change Eclipse-Groovy plugin Groovy libraries?
Asked Answered
F

1

7

I am using the newest version (2.8.0) of the Eclipse-Groovy plugin that ships with groovy-all-2.1.5.jar. I added Guice to my Groovy project, and when I go to run them from inside Eclipse I get the following error in the console output:

Caught: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
    at net.me.myapp.utils.restclient.RestClient.<init>(RestClient.groovy:57)
    at net.me.myapp.inject.UserServiceClientModule.configure(UserServiceClientModule.groovy:34)
    at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
    at com.google.inject.spi.Elements.getElements(Elements.java:101)
    at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
    at com.google.inject.Guice.createInjector(Guice.java:95)
    at com.google.inject.Guice.createInjector(Guice.java:72)
    at com.google.inject.Guice.createInjector(Guice.java:62)
    at net.me.myapp.UserServiceClient.<init>(UserServiceClient.groovy:37)
    at net.me.myapp.UserServiceClient.main(UserServiceClient.groovy:45)
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.typehandling.ShortTypeHandling
    ... 12 more

According to this answer it's because ShortTypeHandling wasn't added until 2.3.x. So I would now like to attach groovy-all-2.3.3.jar to my Eclipse project's classpath.

The problem is that I don't seem to have edit permissions to change what library the Groovy Libraries library uses under the hood. And when I manually add the 2.3.3 JAR to my build path, I get the following error:

Caught: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.1.5 and you are trying to load version 2.3.3

What are my options?

Fiore answered 25/9, 2014 at 19:17 Comment(0)
B
6

Groovy-eclipse versions have its own compilers and are "locked" to them. You may change the versions to whatever is listed under Window > Preferences > Groovy > Compilers, but, AFAIK, you can't change to an arbitrary version of the compiler by simply changing the groovy-all jar in the guts of the plugin dir.

groovy-eclipse compiler version change

You can install new compiler versions using the update site or eclipse marketplace


Update: install additional compiler versions through Help > Install new Software, select Groovy update site and expand the Extra Groovy Compilers session:

enter image description here

Note i'm using snapshot update site, because i like to live dangerously.

Begonia answered 25/9, 2014 at 20:11 Comment(3)
Thanks @Begonia P (+1) - I think you might have found the solution here, however in my eclipse, I don't se a "Switch to 2.3.3.xx..." button/option. I only have buttons for 1.8.7 and 2.0.7, which doesn't help me out because ShortTypeHandling wasn't introduced until 2.3.x. Do you know how I could add more versions to my Groovy Compiler Settings options? Thanks again!Fiore
@Fiore I have the same issue. I installed the 2.4 feature but there's no button to switch to it in my preferences. Did you ever resolve this? Thanks.Commanding
Actually, I found an answer that works for me: add -clean to the eclipse.ini file. Thanks to @Lari Hotari (see #21413503).Commanding

© 2022 - 2024 — McMap. All rights reserved.