July 2013
Intermediate to advanced
370 pages
8h 27m
English
Groovy scripts hold statements and expressions not necessarily confined to a particular class in the source code. We can directly exercise these using the groovy command. We can also invoke them from other Groovy scripts and classes using the GroovyShell class. Let’s look at an example:
| ClassesAndScripts/Script1.groovy | |
| | println "Hello from Script1" |
Here we have a file named Script1.groovy, and we want to execute that script as part of
executing another Groovy script, Script2.groovy, shown here:
| ClassesAndScripts/Script2.groovy | |
| | println "In Script2" |
| | shell = new GroovyShell() |
| | shell.evaluate(new File('Script1.groovy')) |
| | |
| | // or simply |
| | evaluate(new File('Script1.groovy')) |
The ...
Read now
Unlock full access