Does groovy provide an include mechanism?

Groovy treats its files as objects (think of it as of automatic wrapping). And it makes all .groovy files within the java classpath available as classes. So if you have the file util.groovy, that contains something like this inside:

def static AuxMethod() {
    return "Hello World"
}

To call it from another file you just write:

println util.AuxMethod()

That's it. Again, just make sure that your util.groovy file is in the classpath.


To invoke script u.groovy from the current script, passing along the original arguments to the u.groovy, run

run(new File('u.groovy'), args)

Obviously, you could also send any String arguments that you want to:

run(new File('u.groovy'),
        ['one', new File('two.text').absolutePath] as String[])