Use a remporary file to run groovy scripts

Here documents (using <<-GROOVYSCRIPT) do not work properly on windows,
specifically Powershell. This commit switches to using Ruby's tempfile.