【发布时间】:2014-07-28 05:52:54
【问题描述】:
我有一个 groovy 脚本,它需要在外部 groovy 脚本内的类中运行一个方法。 我知道如何在外部 groovy 脚本中运行方法:
new GroovyShell().parse( new File( 'foo.groovy' ) ).with {
method()
}
但是如果方法在一个类中呢?我试过这个,但它给了我一个错误。
new GroovyShell().parse( new File( 'foo.groovy' ) ).with {
theclass.method()
}
【问题讨论】:
-
你能发一个样本
foo.groovy吗?反正theclass好像需要实例化 -
theclass.newInstance().method()
标签: groovy groovyshell