The VM options field is added to the run configuration and you can specify the needed parameters. If you want to add VM options, click the Modify options link and in the dialog that opens, under Java section, select Add VM options. Gradle project - click and select the registered Gradle project. Click inside the field to open the Tasks and Arguments dialog to select the needed options.įor example, specify clean and build, and add the argument -debug. Tasks and Arguments - specify tasks and arguments you want to execute with this configuration. Use the Run section to specify settings for the run configuration.Īs an example, check the following settings: Use the Run on drop-down list to specify the run target option. Also, you can specify where you want to run your configuration. On the right side of the Run/Debug Configurations dialog, in the Name field, enter the name of your configuration. In the Run/Debug Configurations dialog, click and select Gradle to add a new configuration.
The Run/Debug Configurations dialog opens. Select Run | Edit Configurations Alt+Shift+F10. You can create a run configuration for several tasks. IntelliJ IDEA displays the task under the Run Configurations node.ĭouble-click the task to run it or right-click the task and from the context menu select Run.įrom the context menu select Run 'task name'. In Create Run Configuration: 'task name', you can use the default settings or configure the additional options and click OK. Right-click the task for which you want to create the Run configuration.įrom the context menu select Modify Run Configuration. You can add some additional parameters to your task, configure it as a run configuration, save it and use that run configuration in your project whenever you need. IntelliJ IDEA also saves the task in the Run Anything window under the Recent section as well as under the Run Configurations node in the Gradle tool window. IntelliJ IDEA runs the specified task and displays the result in the Run tool window.
If you have options such as offline mode configured for the project, IntelliJ IDEA will automatically include the configuration into the running scope. If you have linked projects and want to run a task for the specified project then in the Run Anything window, in the top-right corner, from the Project list, select the name of the project and in the search field enter the name of your task. Alternatively, scroll down to the Gradle tasks section and select the task you need. To execute several tasks, enter task names using space to separate each new task. In the Run Anything window, start typing a name of the task you want to execute. Alternatively, press Ctrl twice to open the Run Anything window. In the Gradle tool window, on the toolbar, click. Run a Gradle task in the Run Anything window You can also run Gradle command line options through the Run Anything window. You can use several ways to run Gradle tasks such as run them from the Run Anything window, with a run configuration, from a context menu, and even run several tasks with one run configuration. String selectedText = caretModel.getCurrentCaret().getSelectedText() Įven though this action is the same for both editor and console windows, accessing the selected text works the same way.IntelliJ IDEA lets you run, debug and manage Gradle tasks in your project. To get the text to search for, we'll use the Editor API to retrieve highlighted text on the screen: Editor editor = e.getRequiredData(CommonDataKeys.EDITOR) ĬaretModel caretModel = editor.getCaretModel() String languageTag = psiFile.map(PsiFile::getLanguage) In this case, we use the PSI to determine the programming language of a file: Optional psiFile = Optional.ofNullable(e.getData(LangDataKeys.PSI_FILE)) This API parses all the files in a project and provides a programmatic way to inspect them. To get the language tag, we'll use the Program Structure Interface (PSI).