CLion 2025.1 Help

Run/Debug Configuration: Gradle

You can run Gradle tasks using run configuration. The default options listed in such configuration are enough to run your task. If you want, you can also create an advanced configuration using additional options or adding more tasks and arguments.

Create a run/debug Gradle configuration

  1. From the main menu, select Add Configuration. Alternatively, right-click any task in the Gradle tool window and select Modify Run Configuration.

    Gradle configuration settings
  2. Specify a name of your configuration in the Name field to quickly identify it when editing or running the configuration, for example, from the Run popup Alt+Shift+F10 or the Gradle tool window.

  3. If you need, specify Store as project file that saves the file with the run configuration settings, so you can share it with other team members. The default location is .idea/runConfigurations. However, if you do not want to share the .idea directory, you can save the configuration to any other directory within the project.

    To change the location, select this option and click the Manage File Location icon and in the dialog that opens, add the new location.

  4. If you don't need to specify anything in the Run field, the default tasks such as help and tasks specified in the Before build section. section will be executed. Alternatively, if you are creating a run configuration from the Gradle tool window, the task you have selected will be displayed in this field. However, you can specify additional external tasks and arguments for your run configuration. Use spaces to separate one task from another. If you want to see the available list of Gradle tasks and arguments, click the Insert Tasks and Arguments icon in the field.

  5. Specify the location of your Gradle project.

    You can either enter it manually or click the Browse button and point to the desired location in the dialog that opens. However, if you are creating a run configuration from the Gradle tool window, CLion will display the name of your project automatically.

    You can also click Gradle registered projects the Modules node icon to select an available Gradle module from the list of registered Gradle modules in your existing CLion project.

    If you need, you can specify a path to the build script file instead of the project path. This might be helpful if you have a custom build script to which you want to refer.

  6. If you need, specify the environment variables that you want to use in you project.

  7. The following default options are enabled, but you can click Modify options and use the Add Run Options list to add the new options or remove some default ones:

    • Open run/debug tool window when started - automatically opens the Run/Debug tool window when the configuration is executed and several debugger options

    • Debug Gradle scripts - enables breakpoints in the Gradle scripts.

Add Run Options

The Add Run Options list lets you add more run options to the Run/Debug Configurations dialog or remove some of the default ones from it. The list is divided into various sections, so you can easily navigate through the available options.

Gradle configuration settings

Operating System

Item

Description

Allow multiple instances

Select this option to allow running multiple instances of this run configuration in parallel. By default, it is disabled, and when you start this configuration while another instance is still running, CLion suggests stopping the running instance and starting another one. This is helpful when a run configuration consumes a lot of resources and there is no good reason to run multiple instances.

Java

Item

Description

VM options

Specify the options to be passed to the Java virtual machine when launching the application, for example, -mx, -verbose, and so on.

When specifying JVM options, follow these rules:

  • Use spaces to separate individual options.

  • If the value of an option includes spaces, enclose either the value or the actual spaces with double quotes.

  • If an option includes double quotes as part of the value, escape the double quotes using backslashes.

  • You can pass environment variable values to custom Java properties.

-Xmx1024m -Dspaces="some arg" -Dmy.prop=\"quoted_value\" -Dfoo=${MY_ENV_VAR}

Use code completion in this field: start typing the name of a flag, and the IDE suggests a list of available command line options. This works for -XX: and -X options and some standard options that are not configured by CLion automatically, like -ea, but not for -cp or –release.

The -classpath option specified in this field overrides the classpath of the module.

Logs

The following options are related to logging the execution of this configuration. For more information, refer to .

Item

Description

Specify logs to be shown in the console

Specify which log files to display while running the application.

Click the Add button to add a new log. In the Edit Log Files Aliases dialog, configure the following:

  • Alias: The name of the tab where the log will be displayed.

  • Log File Location: Specify the path to the log file or an Ant pattern. If several files of a rolling log match the pattern, CLion will display the most recent one.

  • Show all files coverable by pattern: Show all logs that match the pattern.

For logs in the table, you can configure the following options:

  • Is Active: Display the specified log file.

  • Skip Content: Do not display old log messages from previous runs.

Save console output to file

Save the console output to the specified location. Type the path manually or click the browse button and point to the desired location in the dialog that opens.

Show console when a message is printed to stdout

Activate the console when the application writes to the standard output stream.

Show console when a message is printed to stderr

Activate the console when the application writes to the standard error stream.

Code Coverage

The following options are related to code coverage. For more information, refer to Code coverage.

Item

Description

Specify classes and packages

In this table, specify classes and packages to be measured. Click the Add button and select the Add Class button Add Class or the Add Package button Add Package to specify. You can also remove classes and packages from the list by selecting them in the list and clicking the remove the package button.

Exclude classes and packages

Specify classes and packages that you want to exclude from coverage.

Click the Add button and select the Add Class button Add Class or the Add Package button Add Package to specify classes and packages.

Before Launch

In this area, you can specify tasks to be performed before starting the selected run/debug configuration. The tasks are performed in the order they appear in the list.

Item

Description

Add before launch task

Enable this option to add one of the following available tasks:

  • Run External tool: run an external application. In the dialog that opens, select one or multiple applications you want to run. If it is not defined in CLion yet, add its definition. For more information, refer to External tools.

  • Run Another Configuration: select to execute another run/debug configuration and wait until it finishes before starting the current configuration. If you want to run several configurations in parallel, use a compound run/debug configuration.

  • Run Grunt task: select this option to run a Grunt task.

    In the Grunt task dialog that opens, specify the Gruntfile.js where the required task is defined, select the task to execute, and specify the arguments to pass to the Grunt tool.

    Specify the location of the Node.js interpreter, the parameters to pass to it, and the path to the grunt-cli package.

  • Run gulp task: select this option to run a Gulp task.

    In the Gulp task dialog that opens, specify the Gulpfile.js where the required task is defined, select the task to execute, and specify the arguments to pass to the Gulp tool.

    Specify the location of the Node.js interpreter, the parameters to pass to it, and the path to the gulp package.

  • Run npm script: select this option to execute an npm script.

    In the NPM Script dialog that opens, specify the npm run/debug configuration settings.

  • Compile TypeScript: select to run the built-in TypeScript compiler and thus make sure that all the changes you made to your TypeScript code are reflected in the generated JavaScript files. In the TypeScript Compile Settings dialog that opens, select or clear the Check errors checkbox to configure the behaviour of the compiler in case any errors are detected:

    • If the Check errors checkbox is selected, the compiler will show all the errors and the run configuration will not start.

    • If the Check errors checkbox is cleared, the compiler will show all the detected errors but the run configuration still will be launched.

Open run/debug tool window when started

Depending on the type of configuration, open the Run, Debug, or Services tool window when you start this run configuration. If this option is disabled, you can open the tool window manually:

  • View | Tool Windows | Run or Alt+4

  • View | Tool Windows | Debug or Alt+5

  • View | Tool Windows | Services or Alt+8

Focus run/debug tool window when started

Focus on the run configuration tool window when the tests are running.

Show the run/debug configuration settings before start

Show the run configuration settings before actually starting it.

Gradle

Item

Description

Debug all tasks on the execution graph

When you select this option, every task in the execution graph will be debugged. For example, all the dependent tasks of the task you are trying to debug.

Debug forked Gradle tasks in separate debug tabs

Select this option to run a debugging process in a separate tab in the Debug tool window.

Run as test

By default, this option is disabled. In such case, CLion doesn't open the Run tool window and doesn't rerun tests tasks if they are up to date.

However, if CLion finds test tasks in the run configuration, those are highlighted in the Gradle tool window, CLion doesn't rerun test tasks, but opens the Gradle tool window.

The option becomes enabled when you trigger the test execution from the editor using the Run button in the gutter or the context menu.

In this case, CLion opens the Run tool window and reruns the test tasks each time the execution is triggered even if the tests are up to date.

This option might be helpful in controlling the rerunning process of the test tasks in your project.

Last modified: 10 April 2025
OSZAR »