Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

java - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...