Eclipse API to decorate Groovy Script code

I tried formatting the code to format the Eclipse code to format the Java code for my web project requirement. Now I am looking for something similar for Groovy. Can someone tell me how to do the same for Groovy?

+3
java eclipse groovy
source share
2 answers

There is no syntax highlighting, it's so grim ...!

The Aaron D recommendation on using the Eclipse Marketplace did not work for me: the versions are outdated, the installation attempts were unsuccessful. This is what worked for me (neon, then oxygen after a few months)

  • go here https://github.com/groovy/groovy-eclipse/wiki
  • in the "Snapshots" section (lower than the "Releases", which are available only in Eclipse Luna at the time of writing), find and copy the link for your version of Eclipse
  • in Eclipse go to Help β†’ Install new software
  • Work with β†’ paste: http://dist.springsource.org/snapshot/GRECLIPSE/e4.6/ (from the site above: the correct version for Eclipse Neon) (2018-01-03 http://dist.springsource.org/ snapshot / GRECLIPSE / e4.7 / : Oxygen)
  • click add
  • check the item "Groovy-Eclipse" β†’ Next β†’ Next β†’ Accept, Finished installed (took a lot of time: progress is indicated at the bottom right)
  • restart eclipse
  • Window β†’ Prefs: now there is a "Groovy" element
  • Groovy -> Compiler -> Groovy Script Folders: checked "** / *. Gradle"
  • Apply: "must complete the assembly" ...
  • restart eclipse again
  • * .groovy and * .gradle: syntax highlighting! automatic formatting!

update 2019-08, Eclipse version 4.12 ("2019-06")

There is currently no Groovy-Eclipse element to select / select! It seems that my experiments show that in the "Installation" dialog box you need to check the "Main package" and the item "Maven support".

OTOH, it seems that the .gradle files then work with this editor out of the box, no configuration is required.

Thanks for making this a little more confusing and less comprehensible guys!

+3
source share

Get the Groovy plugin from the Eclipse website (help menu). It can format Groovy code, but the result is not as good as the one from Java formatting (Groovy is a very complex language from the point of view of the parser).

+1
source share

All Articles