Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse API to beautify Groovy Script code

I tried the Eclipse code formatter Eclipse code for-matter to format Java code for my web project requirement. Now I am looking for something similar for Groovy. Can any one tell me how do the same for Groovy as well?

like image 503
JavaBeigner Avatar asked Mar 12 '26 09:03

JavaBeigner


1 Answers

No syntax highlighting is so glum...!

Aaron D's recommendation to use the Eclipse Marketplace didn't work for me: versions out of date it seems, installation attempts failed. This is what worked for me (Neon, then Oxygen a few months later)

  • go here https://github.com/groovy/groovy-eclipse/wiki
  • under "Snapshot builds" (lower down than "Releases", which only go up to Eclipse Luna at time of writing), identify and copy the link for your Eclipse version
  • in Eclipse go Help --> Install new software
  • Work with --> paste: http://dist.springsource.org/snapshot/GRECLIPSE/e4.6/ (from above site: 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, Finish installed (took long time: progress indicated at bottom right)
  • restart of Eclipse
  • Window --> Prefs: there is now a "Groovy" item
  • Groovy --> Compiler --> Groovy Script Folders: checked "**/*.gradle"
  • Apply : "must do full build"...
  • restart Eclipse again
  • *.groovy and *.gradle : syntax highlighting! auto-formatting!

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

At this point there is no "Groovy-Eclipse" item to highlight/choose! My experiments seem to show that in the "Install" dialog you have to check the "Main package" and the "Maven support" thing.

OTOH it seems that .gradle files then work with this editor out of the box, no config needed.

Thanks for making it a little bit more confusing and less self-explanatory, guys!

like image 90
mike rodent Avatar answered Mar 14 '26 23:03

mike rodent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!