简体   繁体   中英

Groovy not compiling properly in Eclipse

I'm trying to write my first groovy class. When I do so, Eclipse complains about syntax errors as though it's parsing a Java file. It wants semicolons on the end of each line, it doesn't recognize the "def" keyword, etc.

I have both Groovy 1.7.5 and the latest Groovy Eclipse plugin installed. I have also converted the project to a Groovy project and opened the file in the Groovy editor.

What else could be causing this:

替代文字


EDIT:
update - even when I disable all builders via project properties > builders , I still get the red lines. What causes this? I thought the builders were responsible for creating the lines and markers??? If I can figure out "who" determines errors/problems in an open workspace file, I could deactivate that functionality...

I have seen this before. My usual response to resolve this is to:

  1. Close / reopen the project.
  2. Confirm the project is converted to a groovy project
  3. Clean and rebuild the project.

If that doesn't work...You can try to create a new project with the existing source.

good luck!

The AspectJ/Groovy combination is not working inside of Eclipse. They each require their own builder and they are not compatible with each other. The only way that this will work is if you separate your AspectJ and your Groovy code into different projects.

This combination may work in Maven since it can use different compilers for different source folders. However, there may be a circularity problem your aspect code depends on your groovy code (which in turn depends on your aspect code).

I found that updating to the latest snapshot build fixed my compile issues.

http://jira.codehaus.org/browse/GRECLIPSE-1003

Put this into your install new software...: http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.6/

I'm seeing the same problem. I also get an error when I try to create a new Groovy script or class. I get an error dialog saying:

org.eclipse.jdt.internal.core.CompilationUnit cannot be cast to
org.codehaus.jdt.groovy.model.GroovyCompilationUnit

I've tried moving the Groovy source files to a different folder that is not set as a Java source folder, and the syntax error highlighting problem goes away, now. I still have to avoid doing "New > Groovy Class", though. I just create a plain file and name it with a ".groovy" extension, and it seems to be OK with that.

Clearly there are significant issues with this plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM