Run groovy scripts in sublime text

Wondering how to run Groovy files in Sublime Text? It’s really quite simple – to create a new build system in Sublime Text go to Tools > Build System > New Build System and copy/paste the code below

{
  "cmd": ["groovy","$file"],
  "selector": "source.groovy",
  "windows":
  {
    "shell": "cmd.exe"
  }
}

Once the build system is saved you should be able to type Ctrl + B to run the code and output to the Sublime console. If nothing happens you may need to go to Tools > Build System and select groovy.

This is extremely handy if you’re creating tests in Grails and want to test things without creating a full test case beforehand, writing/running tests in Grails can be excrutiating and testing within your file can help you spot mistakes much quicker than running test-app and waiting for everyting to compile and output your results.

Matt Busche's Picture

About Matt Busche

Software Engineer and Wheel of Fortune Expert If this article helped you, please consider buying me a book.

Des Moines, IA https://www.mrbusche.com