January 20, 2016

Ratpacked: Debugging Application Defined Using Groovy DSL In IntelliJ IDEA

When we want to debug our Ratpack application written in Java we can simply use the Debug action on the main application class. When we described the application with the Groovy DSL we must add a Groovy runtime configuration to our project in IntelliJ IDEA to support debugging of the (R|r)atpack.groovy script file.

First we select Run | Edit configurations.... IntelliJ IDEA opens a new dialog window where we can add or modify run/debug configurations. We select the option New configuration and choose the option Groovy:

Next we must set properties for this runtime configuration. We can give a descriptive name and must set Script path to the Groovy script file with our Ratpack application. This would normally be the file ratpack.groovy and Ratpack.groovy in the directory src/ratpack. We also set the Module to our project and then we are ready:

Now we can add breakpoints in the Groovy script file (R|r)atpack.groovy and select Run | Debug 'Ratpack' to start the Ratpack application in debug mode.

Written with Ratpack 1.1.1 and IntelliJ IDEA 15.