Groovy in Eclipse does not recognize import

I am trying to run a Groovy script in Eclipse, but Eclipse seems to ignore all my import statements. If I hover over errors, it tells me to import the corresponding class (clicking on it does nothing).

I have the necessary 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 allow Bar class

Any help would be appreciated.

+7
source share
4 answers

Forgot to build a project. Uch. (build was automatically disabled in Eclipse)

+1
source

Three possibilities:

  • script is not in source folder
  • The sent script is not in the source folder.
  • One or both of the scripts are in the script folder. script folders are folders in which scripts go. Groovy files in script folders are not sent to the compiler, so scripts in script folders cannot link to each other. Check the script folder under "Settings" -> Groovy -> Compiler. In addition, there are project-specific script folders with groovy -eclipse 2.6.1, so also check the project properties.
+4
source

There was the same problem. Adding these objects to my .classpath solved the problem:

 <classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/> <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/> 
0
source

I had this problem when I imported an existing groovy project into the IDE before installing the Groovy Development Tools plugin.

I installed the Groovy plugin and restarted the IDE, but my project was still corrupted.

So I deleted the project and imported it again, and then the problem disappeared.

0
source

All Articles