jastrachan | 16 Apr 14:29 2004
Picon

Re: Calling scripts within scripts

On 16 Apr 2004, at 12:52, Kevin Jones wrote:
> Can one groovy script call another script dynamically.
>
> I want to run a script that reads a configuration file. That 
> configuration
> file contains the names other script files. Can I execute those script 
> files
> dynamically, i.e. can I do something like
>
> main(args)
> {
>     call someFileName.groovy
> }
>
> If not directly, is there a way of achieving this?

the easiest way of doing this is via a GroovyShell.

shell = new GroovyShell()
shell.evaluate(new File("foo.groovy"))
shell.evaluate("for (x in 1..10) { println "hello ${x}" }')

etc

Or if your scripts are written as classes, you could just refer to 
static methods etc

main(args) {
     SomeOtherScript.someStaticMethod(123)
}

James
-------
http://radio.weblogs.com/0112098/

Gmane