Skip to content
Advertisement

Eclipse error when trying to configure for using Groovy in a Gradle project

On a Windows machine I’ve been using Groovy in Gradle projects in Eclipse for some time now. Now I’m trying to configure for a Linux machine. (Linux Mint MATE). uname -a gives this:

Linux mike-Latitude-E6410 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:58:04 UTC 2016 i686 i686 i686 GNU/Linux

Eclipse Oxygen. Installed Groovy (2.4.15) using this link: http://dist.springsource.org/snapshot/GRECLIPSE/e4.7/

Installed Gradle (4.7) using Buildship Gradle Integration 2.0.

Then I put this line in build.gradle:

compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.15'

I make a new “source directory” under the project: src/test/groovy.

I make a new file under that: “Test.groovy”.

I put one line in that: println "hello world".

Without changing the “source sets” in build.gradle yet I now see one of those dreaded “red exclamation marks” next to the one line of the file. The message is:

Multiple markers at this line
    - The type groovy.lang.GroovyObject cannot be resolved. It is indirectly referenced from required .class files
    - The type groovy.lang.MetaClass cannot be resolved. It is indirectly referenced from required .class files
    - implements groovy.lang.Script.run

There are surprisingly few reports (particularly recent ones) of this problem in SO or more generally when I search.

One suggests adding the Groovy Runtime Libraries to the build path configuration … did that: not solved.

NB I have also tried repeatedly 1) rebuilding the project 2) refreshing Gradle 3) running the “build” task 4) closing Eclipse and starting up again.

NB2 I have not yet installed Groovy or Gradle in the general system: only for Eclipse. Could this be anything to do with it? Seems unlikely.

Advertisement

Answer

Seems like this was a “schoolboy error”.

I just had to include this line in build.gradle (I haven’t currently got access to my other machine so wasn’t able to make the comparison).

apply plugin: 'groovy'

Will leave the question, unless there is massive objection, because it might help others who get puzzled…

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement