How to Debug a Groovy Script From Shell
Groovy is a dynamic language with powerful capabilities for typing and compilation on the Java platform; use this snippet to debug it without compiling.
Join the DZone community and get the full member experience.
Join For FreeGroovy is a scripting language, so it is possible to run Groovy code without compiling to Java byte code. The necessary condition is that Groovy is installed on your machine. Then, running a Groovy script in a shell looks like the following line:
~>groovy TestScript.groovy
Now, something is wrong with the script on a special environment. You want to debug your Groovy script from the shell.
Fortunately, it works for Groovy just like for Java. You only have to export the Java options for debugging:
~>export JAVA_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=y"
Now, we can debug our script running from the shell with our favorite IDE.
~>groovy TestScript.groovy
Listening for transport dt_socket at address: 4000
Published at DZone with permission of Sandra Parsick, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments