Getting started with Grails
Last modified: 01 August 2022IntelliJ IDEA supports Grails version 3.0 and later.
tip
For working with Grails older versions, refer to the Getting started with Grails 1/2 section.
The easiest way to create a Grails project is to generate one with the Grails Application Forge where you can quickly fill in a template, and then import the generated template project into IntelliJ IDEA. In this case, the Application Forge automatically sets all required dependencies according to the selected features and profiles.
Open the generated template Grails project
Starting with the Grails 3.0 version, Grails projects use Gradle build system. You can use Gradle to open your project. IntelliJ IDEA imports the project and creates the specific folder structure and all the necessary artifacts.
From the main menu, select File | Open and the build.gradle file or a directory containing the build.gradle file.
In the dialog that opens, click Open as Project.
IntelliJ IDEA creates a fully-functional Grails project with the predefined structure, Gradle build file and a set of libraries.
tip
If you need more information on working with Gradle in IntelliJ IDEA, refer to the Gradle section.
Create a Grails project with Application Forge inside IntelliJ IDEA
You can use the Application Forge that is integrated with IntelliJ IDEA and create a Grails project through the project wizard.
If no project is currently open, click Create New Project on the welcome screen; otherwise select File | New | Project.
On the page that opens, in the left pane, select Application Forge.
Select the JDK that you want to use in your project.
If the JDK is installed on your computer, but not defined in the IDE, select Add JDK and specify the path to the JDK home directory.
If you don't have the necessary JDK on your computer, select Download JDK.
Select Grails options from the available template, and click Next.
On the next page, specify the project information and click Finish.
IntelliJ IDEA generates a Grails project with the Gradle build file and all needed libraries.
Explore Grails application
There are some notable differences in the Grails project structure as appose to projects with older Grails versions (1 and 2):

build.gradle - the Grails versions 3.0 and later use Gradle for building.
config directory - the content of the config directory enables you to use either a YAML file or Groovy file for your configuration. The logging configuration is also available.
init directory - this directory contains main application file the lets you run your application with default settings.
The Grails view is supported.
All the Project view settings are available for the Grails view as well.
Grails actions are available in the Project view. All artifact icons are changed to Grails icons ('project name' | New).
For more information on the differences, refer to the Grails documentation.
Run Grails application
When you create a new or open the existing Grails project, IntelliJ IDEA automatically creates a run/debug configuration along with your project. The information specified in such a configuration is enough to run the application. You can click on the main toolbar to execute it. If you want to edit the created run/debug configuration, from the main menu select Run | Edit Configurations.

tip
If the created run/debug configuration doesn't have a name of the application specified in the Application field, try to reopen your project.
You can also run your application from the editor:
In the Project tool window, click the init folder.
From the list, select Application.groovy to open the file in the editor.
In the editor, in the left gutter, click
and in the window that opens click Run 'Application main()'.
Your application starts in the default browser, with the following URL in the address bar: http://localhost:8080/.
Debug Grails application
IntelliJ IDEA lets you debug your Grails application using Application.groovy.
In the Project tool window, open init directory and right-click the Application.groovy
From the list select Debug Grails:'name'
You can also use the editor to start the debugging process.

IntelliJ IDEA displays the results in the Debug tool window.
Debug Grails application with Gradle tasks
IntelliJ IDEA lets you also debug your Grails application using Gradle tasks.
Open the Gradle tool window.
From the list of tasks, click application and in the list that opens, right-click bootRun.
From the list that opens, select Debug Grails:'name'.
IntelliJ IDEA displays the results in the Debug tool window.
Grails coding assistance
You can use the following coding assistance in your Grails project:
IntelliJ IDEA provides navigation between all related files such as domain classes, views, services, and controllers. Press Ctrl+Alt+Home in the editor and choose your target.
IntelliJ IDEA provides navigation between the injected dependencies.
IntelliJ IDEA also provides navigation between the methods of the controller and gsp files.
IntelliJ IDEA lets you open and check the hierarchy of the domain classes. Press Ctrl+H in the editor to open Hierarchy tool window.
IntelliJ IDEA also lets you check the domain classes dependencies.
Thanks for your feedback!