Earlier this week a colleague and I was working on a Groovy introduction presentation and we had decided on using textmate. So we downloaded the capable Groovy textmate bundle from Github. I had been using the Groovy console and found the performance for running small groovy snippets to be rather unbearable with the textmate plugin though. You got the startup cost of firing up the jdk+groovy and it opened a new window. This was not what I remembered, and it certainly wouldn't work for a code driven presentation. A quick google found a youtube video with Dierk König. Aha of course Groovyserv to the rescue.
So the short version:
- Got Homebrew ? Well then just brew install groovyserv
- No ? Install it (if you don´t have xcode either... I suggest you download groovyserv manually unless you have the time to spare. People complain about maven downloading the internet, xcode feels pretty close)
- In textmate select bundles->bundle editor->edit commands
- Add a command for running the current file. The following settings might work for you:
- Save current file (usually what I want)
- Commands : /usr/local/Cellar/groovyserv/0.9/libexec/bin/groovyclient -encoding "UTF-8" "$TM_FILEPATH"
- Input : Entire document
- Output: Show as tooltip (worked out real nice in the presentation)
- Activation : cmd+h (or something that suits you... that particular combination has a somewhat different behaviour in the GroovyConsole btw)
- Similarily if you just want to run a selection just change command to something like:
- /usr/local/Cellar/groovyserv/0.9/libexec/bin/groovyclient -c "UTF-8" -e "$TM_SELECTED_TEXT"
- Unlike the console it doesn't output the last executed statement, so if you are doing oneliners you better remember println ! (If anyone has any tips for that one in Textmate, feel free to comment on the post)
You are all set to run nice little groovy snippets with near instant responses (well the first time you try it, groovyserv will incur a heavy startup cost. But after that you are good to go in kickass speed).