IntelliJ IDEA 2016.3 Help

Getting Started with Groovy

IntelliJ IDEA lets you create and run Groovy applications.

Before you start working with Groovy, make sure that the Groovy plugin is enabled in IntelliJ IDEA.

Creating Groovy Project

  1. Open Project Wizard, in the left-hand pane select Groovy.
  2. In the right-hand pane, specify the following settings:
    • Project SDK - specify your project SDK.
    • Groovy library - specify your Groovy SDK or click Create to choose one from the list that opens.
    • Additional libraries and frameworks - specify additional libraries and frameworks that Groovy supports.
    • Java EE version - select the appropriate Java EE version.
      /help/img/idea/2016.3/groovy_create_project.png
  3. Click Next.
  4. Specify your project information and click Finish.
    /help/img/idea/2016.3/groovy_project_info.png

Adding Frameworks to Existing Groovy Project

  1. In the Project tool window, right-click the project directory and from the drop-down list select Add Framework Support.
    /help/img/idea/2016.3/groovy_add_framework_support.png
  2. In the Add Frameworks Support dialog, select a framework and click OK.
    /help/img/idea/2016.3/add_frameworks_support_dialog.png

Creating Groovy Class

  1. Press Ctrl+N or in the Project tool window right-click on the directory and select New | Groovy Class
  2. In the New Groovy Class dialog, in the Name field, specify a name of the class. In the Kind field, choose between class, interface, trait, enum or annotation.
    /help/img/idea/2016.3/groovy_new_class.png
  3. Now you can enter your code.
    /help/img/idea/2016.3/groovy_sample_code.png

Creating Groovy Script

  1. Press Ctrl+N or in the Project tool window right-click on the directory and select New | Groovy Script.
    /help/img/idea/2016.3/groovy_new_script.png
  2. In the dialog that opens, in the Name field, enter the name of your Groovy script. In the Kind field, choose between Groovy script and GroovyDSL script.
    /help/img/idea/2016.3/groovy_new_script_dialog.png
  3. IntelliJ IDEA creates a file with the specified name and groovy extension, and adds a node to the module tree view.

Running Groovy Application

  1. Create a Run configuration using Run | Edit Configurations or run the active script automatically by pressing Ctrl+Shift+F10.
    /help/img/idea/2016.3/groovy_script_running.png
  2. View the result in the Run tool window.

See Also

Last modified: 21 March 2017