CLion 2019.1 Help


Gradle is a build automation system that provides plugins to build C/C++ libraries and applications. In CLion, you can work with Gradle projects that are based on cpp-application and cpp-library plugins (for more details on C/C++ Gradle plugins, see this blog post: Introducing the new C++ plugins).

Opening a Gradle project

Select File | Open from the main menu, choose the build.gradle file, select Open as a Project, and provide the Gradle settings (you can change these settings later in the Settings/Preferences | Build, Execution, Deployment | Gradle dialog):

Gradle project initial settings
  • Use auto-import - select this option to enable auto-importing Gradle settings for your project.

  • Use default gradle wrapper (recommended) - select this option to use Gradle wrapper. In this case you delegate the update of Gradle versions to Gradle and get an automatic Gradle download for the build. It also lets you build with a precise Gradle version. The Gradle version is saved in the file in the Gradle directory of your project. We recommend that you use this option to eliminate any Gradle version problems in your project.

  • Use Gradle local distribution - select this option if you want to manually download and use a specific Gradle version. Specify the location of your Gradle installation and JVM under which CLion will run Gradle when you import the specified Gradle project and when you execute its tasks.

  • Gradle JVM - provide the path to JVM location.

Creating a Run/Debug configuration for a Gradle project

If you use Auto-import when opening a Gradle project, CLion extracts Run/Debug configurations from the build.gradle file. You can change the extracted configurations and create new ones via the Run | Edit Run/Debug Configurations dialog.

In CLion, there are two Run/Debug configurations available for Gradle projects: gradle common icons toolWindowGradle svgGradle and icons runConfigurations applicationGradle Native Application.

Setting up a Gradle configuration

  • In the gradle common icons toolWindowGradle svg Gradle configuration dialog:

    Gradle project

    - click cl gradle prjicon and select the registered Gradle project:

    Choose Gradle project


    - specify tasks you want to execute with this configuration. Note that you can run several tasks in one Run/Debug configuration. For example, specify clean and build.

    VM options

    - use this field to customize VM options.


    - you can specify Gradle command line parameters. For example, specify --debug.

Setting up a Gradle Native Application configuration

  • In the icons runConfigurations application Gradle Native Application configuration dialog:

    • In the Target field, select the desired target from the list:

      List of targets for Gradle Native Application

    • In the Executable field, select the proper executable for your configuration.

Working with Gradle tasks

CLion lets you run Gradle tasks using several different ways such as using a toolbar in the Gradle tool window, using a run configuration, and using a context menu.

Running a Gradle task from the Gradle toolbar

  1. In the Gradle tool window (View | Tool Windows | Gradle), click gradle common icons toolWindowGradle svg on the toolbar.

  2. In the Run Gradle Task dialog that opens, start entering the name of the task in the Command line field. CLion displays the list of Gradle tasks from which you can select the appropriate one:

    Run Gradle task

  3. CLion runs the selected task and displays the result in the Run tool window:

    Run Gradle task
    CLion also saves the task under the Run Configurations node in the Gradle window:
    Run Gradle task

Using context menu to run a Gradle task

  • The first option is to select Run from the context menu of the desired task in the Gradle projects tool window.

  • If the task already has a corresponding Run/Debug configuration, you will see the Select option in the context menu. You can use this option to set the active configuration, and then run it.

    Run Gradle task

  • If there is no corresponding configuration for the task, the context menu will contain the Create option. Choose this option to open the Run/Debug Configuration dialog and create a configuration with the selected task.

  • All the available Run/Debug configurations are listed under the Run configurations node. Use the Run option from the context menu to run the tasks presented under this node:

    Run Gradle task

Running Gradle Native applications

In CLion, you can run and debug a Gradle Native application in the same way as a regular application.

For example, you can use the artwork icons run play icon in the left gutter beside the code entry points. Click artwork icons run play and choose the desired action from the list. If there is no existing Gradle Native configuration for the target, a new configuration will be created before the launch.

Run gutter

Issues and limitations

In the current initial phase of the Gradle support in CLion, there are several known problems and functionality restrictions:

  • CLion does not provide a project template for Gradle, so you can't create a new Gradle project via the New Project wizard.

  • Debugging Gradle tasks themselves is unavailable.

Last modified: 24 July 2019