Eclipse pulls in untwanted 2.4.4 version of Groovy causing error


(Steve Cohen) #1

Continuing the discussion from How do I fix the "Spock 1.0.0-groovy-2.4 is not compatible with Groovy 2.3.10" error?:

This error is also evident in Eclipse. I imported a Gradle project (not a multi-project so I had some hope of being able to build it with buildship see my other post). I just used the standard project input settings which gave me a gradle 2.11 base, and I find that groovy-all-2.4.4 jar is pulled in from there as a dependency. It is not getting pulled in by any of my code.

This always produces the following error

Groovy:Unexpected problem with AST transform: The Spock compiler plugin cannot execute because Spock 1.0.0-groovy-2.4 is not compatible with Groovy 2.3.10. For more information, see http://versioninfo.spockframework.org

at line 1 of one particular groovy file in my source. Why there and not somewhere else is a mystery but it’s also apparently a false positive, as I can actually build the project with gradle from within Eclipse. It’s just an annoying and apparently meaningless eyesore. It’s not particular to buildship either, the same happened when I was using the Spring tooling for Gradle.

By the way, the link in the error message above contains no useful information.


(Stefan Oehme) #2

Gradle does not just add dependencies to your project. Run

gradle dependencyInsight --dependency groovy-all

to see who pulls it in.


(Steve Cohen) #3
$ gradle dependencyInsight --dependency groovy-all
:dependencyInsight
org.codehaus.groovy:groovy-all:2.4.4
\--- compile

So it seems to be being called in by default by the compile task. I didn’t ask for this, but it is standard in gradle 2.11. The question then is how do I downgrade the groovy compiler used by Eclipse so my project can be built in Eclipse? And preferably with an Eclipse setting so I don’t have to put this in all my build scripts?


(Stefan Oehme) #4

Again, Gradle does not just add dependencies to your project. Please attach a little example project that reproduces this problem.


(Steve Cohen) #5

Well you were right, at least partially. I did have an explicit dependency on Groovy 2.4.4 in the build script for my plugin. But - replacing that with 2.3.10 did not make the problem go away. Neither did removing the explicit groovy dependency altogether. Again - Gradle succeeds at building my project either in Eclipse or on the command line, but this annoying error mark in Eclipse refuses to go away, with either groovy-2.4.4, groovy-2.3.10 or no version of Groovy specified.

My project simply contains groovy files. It is a project that builds a collection of gradle plugins and tasks. That may have something to do with it.

Here is my current theory: There is a bug somewhere either in Eclipse or BuildShip. The gradle instance launched there for background compilation knows it has to use some version of a groovy compiler to compile it, so it goes for the newest one (Gradle’s default strategy according to Users’ Guide) available on its classpath, which is 2.4.4 distribution.

If you want me to put together a simple test case I will try to do this.


(Stefan Oehme) #6

This is important, you should always include such information up-front :slight_smile: If you build a Gradle plugin, you are using gradleApi, which includes Groovy 2.4.

The error message from Spock is actually pretty clear: You have selected Groovy 2.3 as the compiler in Eclipse (see Preferences -> Groovy -> Compiler). This won’t work with a project that needs Groovy 2.4


(Steve Cohen) #7

Yes, but I have not chosen Groovy 2.3, or rather, yes, I did because the only other choice Eclipse gave me was 2.0.7! How can I make Groovy 2.4.4 available within Eclipse? Or could I simply disable Spock, which I am not even using?


(Stefan Oehme) #8

You need to install the 2.4 compiler from the Groovy Eclipse update site.

As to Spock: You’re using it, otherwise you wouldn’t get that error message :slight_smile:


(Steve Cohen) #9

Thanks, issue solved. I think I installed groovy originally from the Eclipse Martketplace which did not have the latest.


Eclipse Java Errors on gradle project even though Gradle can build project