Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Groovy in Eclipse not recognizing imports

I am attempting to run a Groovy script in Eclipse but Eclipse is seemingly ignoring all of my import statements. If I hover over the errors it tells asks me to import the appropriate class (clicking on it does nothing).

I have the required jars in my build path and class path.

Sample code, pretty standard:

package scripts.blah

import foo.Bar;

class FooMain {
    static main(String[] args){
        Bar bar = new Bar();
    }
}

Groovy:unable to resolve class Bar

Any help would be appreciated.

like image 453
smcg Avatar asked Mar 30 '12 19:03

smcg


1 Answers

Three possibilities:

  1. The script is not in a source folder
  2. The script being referred to is not in a source folder.
  3. One or both scripts are in "script folders". Script folders are folders where scripts go. Groovy files in script folders are not sent to the compiler and therefore scripts in script folders cannot reference each other. Check out your script folder at Preferences -> Groovy -> Compiler. Also, as of groovy-eclipse 2.6.1, there are project specific script folders, so also check in your project properties.
like image 118
Andrew Eisenberg Avatar answered Oct 08 '22 20:10

Andrew Eisenberg