IntelliJ IDEA lets you launch a Groovy shell for Groovy projects and Grails applications to evaluate Groovy expressions,define classes and run simple experiments.

Before you launch a Groovy shell, make sure that the Groovy 2.2 library version is downloaded.

In this section:

To launch groovy shell
  1. On the main menu, choose Tools | Groovy Shell.
  2. If your project consists of two modules or more, choose the module to use the classpath of:

    Groovy_Module_Shell

    The Groovy shell starts in a separate tab of the Run tool window:

To use groovy shell
  • Type code in the console after the prompt character, or just paste from the editor tab.

    Note that coding assistance is available, as you type (code completion and error highlighting):

    GroovyShellCodeAssistance

  • Click runBuild, or press ⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎^ Enter, ⌃⏎ or ⌃⏎^ Enter, ⌃⏎ or ⌃⏎ to execute the entered code.
  • To start a new line, press or or or Enter, or Enter, ^ M, , ⌃M, or ⌃M.
  • Use up and down arrow keys to navigate through the history of commands. Depth of the history is defined by the Console commands history size in the Editor settings.
  • Use the basic and advanced editor shortcuts. In particular, you can jump to declaration of a symbol, if you place the caret at the symbol name, and press ⌘B, ⌘Button1 Click, Button2 Click, ⌘B, ⌘Button1 Click or Button2 Click⌘B, ⌘Button1 Click, Button2 Click, ⌘B, ⌘Button1 Click or Button2 ClickF3, ⌃Button1 Click, F3 or ⌃Button1 ClickF12, ⇧ F2, ^ B, ^ Button1 Click, Button2 Click, F12, ⇧F2, ⌃B, ⌃Button1 Click, Button2 Click, F12, ⇧F2, ⌃B, ⌃Button1 Click or Button2 Click^ ⌥ G, Escape, Period, ⌥ Period, ^ Button1 Click, ⌃⌥G, ⎋, ., ⌥., ⌃Button1 Click, ⌃⌥G, ⎋, ., ⌥. or ⌃Button1 Click. Alternatively, keep the ^ key pressed, and hover your mouse pointer over the reference to a symbol. So doing, brief information appears at the tooltip, and the reference turns to a hyperlink, which allows you to jump to the declaration in the source code.

See Also

Concepts: