How to Run Groovy test cases with Groovy Jar

Assume that you have a groovy file (test.groovy) and you want to run it with Groovy jar. Follow the below steps to do it.

Here is the test.groovy file

//test.groovy
println "test"

Then download the groovy.jar, If you don’t have it.

curl -s -L -o groovy.jar \
       "http://central.maven.org/maven2/org/codehaus/groovy/groovy-all/1.8.1/groovy-all-1.8.1.jar"

Then run the test file with the below command.

  java -cp groovy.jar groovy.lang.GroovyShell test.groovy