Leikingo
Leikingo

Reputation: 940

Running a groovy script in eclipse

I'm currently writing some groovy scripts. Till now I simply use notepad and run the scripts via groovy script.groovy. But I'm looking some help for editing the files. So I tried eclipse with the groovy plugin which looks great...for groovy projects. But I just want to edit and run the groovy scripts. No Project dir etc.. What's the best way to handle scripts in eclipse. I don't want to package the files to jars or something like that. I have just a folder with some scripts in it... No src/bin directory or subfolders for package names. Is that possible?

Thanks, Ingo

Upvotes: 16

Views: 35681

Answers (3)

Steve
Steve

Reputation: 4695

This solution still requires a "project", but aims to use Eclipse to do it in the least invasive way.

http://andrewclement.blogspot.com/2009/12/using-eclipse-to-edit-your-groovy.html#!/2009/12/using-eclipse-to-edit-your-groovy.html

Then you can use the "run as" as stated by Mr. Floyd :D

Upvotes: 0

Dónal
Dónal

Reputation: 187399

It sounds like Eclipse is a bit heavyweight for your needs, have you considered using the GroovyConsole instead? It's a very simple Groovy IDE, available in the Groovy bin directory. Assuming you have this directory on your PATH, you can start it by running groovyConsole from the command line.

Useful shortcuts are:

  • Ctrl + R : run the script
  • Ctrl + W : clear the output

Upvotes: 3

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 299218

You must convert your project to a Groovy project (right-click project: Configure > Convert to Groovy Project), but then, sure, it's possible.

When editing a .groovy file, select Run > Run as ... > Groovy Script

Upvotes: 16

Related Questions