Hi,
I am trying to run a Groovy Script from a file. All Calls (Method/Property)
from that Script should be redirected in a nice and easy way to the Class,
which is running the Script Object.
I tried something like this.
class TestClass {
void pln(String txt) {println txt}
void run() {
Script dslScript = new GroovyShell().parse(new File("script.txt"))
dslScript.metaClass = this.metaClass
dslScript.run()
}
static void main (String[] args) {
TestClass t = new TestClass()
t.run()
}
}
with "script.txt":
println "println success"
pln "pln success"
The first call is of course succeeded, but on the second line i get a
MissingMethodException: No signature of method: Script1.pln() is applicable
for argument types: (
java.lang.String) values: [pln success]
What is going wrong? How can i solve this problem easily?
Cheers
--
Sent from the groovy - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email