Question

I often want to test methods I'm developing in a Groovy class independently, and use the Console to do so, like:

groovyConsole -cp mygroovyfiles

However I have not yet been able to figure out how to reload changes to my groovy files so that I can update the files and see the results reflected in the Console. "/Script/Add Directory to ClassPath" and "Script/Clear Script Context" don't work. Is this possible?

Était-ce utile?

La solution

I don't believe it is possible in the groovyConsole. The groovysh, however, is a different story. The groovysh has a \l command which lets you reload a script. I don't know if this helps you, but it works for me. A session would look like this...

bobk-mbp:~ bobk$ cd work/workspace/ZGroovyProject/
bobk-mbp:ZGroovyProject bobk$ emacs src/Hello.groovy 
bobk-mbp:ZGroovyProject bobk$ groovysh
Groovy Shell (1.8.3, JVM: 1.6.0_29)
Type 'help' or '\h' for help.
-----------------------------------------------------------------------------------------------------------------------------------
groovy:000> \l src/Hello.groovy 
hello, world.
===> null
groovy:000> \l src/Hello.groovy 
hello, world from bob
===> null
groovy:000> 

Autres conseils

You may try to clean your buffer before you reload the script

>clear
>load src/Hello.groovy
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top