Any action to pause IntelliJ when doing e.g a build out of IDE?

I am working on a relatively large project and building the project as whole will happen out of IDE. (Maven build) the problem is that during the mvn clean install. The IDE tries to build the project on its own and the external maven prject does it out of IDE and this cause the IDE to go very slow as there are two builds happening in parallel. What I am looking for is to just pause the IDE scanning and building for a period of time using some shortcuts or menu items.


Comment actions Permalink

Are you sure IntelliJ IDEA is doing a build? IDEA never runs a build unless it is part of another event. For example running a build directly (obviously) or running a run/debug configuration -- including a unit tests and temporary (i.e. on the fly) ones -- that have the option to "Make before running" selected (which is the default). Changing the source code or built classes (which is what maven would be doing) will not trigger a build.

What I suspect is happening is indexing. You can verify this by opening the background tasks dialog when this is happening. Just click on the progress bar (located to the right of center) in the bottom status bar. You'll then be able to see the name of the process that is running.

All the project's I've been working on for the past 4-5 years have been large (30-40 modules) maven projects.  And I have never seen IDEA run a build when I run a maven build even when run externally. However, on a few occasions, I have seen it do indexing. This will not happen with a "standard" maven project. The reason is that the target directories where the built classes get put are excluded from indexing. And since the build is not changing the source code, there is nothing to index.  Where this will vary, and indexing will happen, is in the following situations:

1) The maven build creates generated source code.
IDEA sees the new generated code and indexes it so it can include it in searches, code completion, etc. If your build is generating a lot of source code, there is a lot to index. This has to be done if you want to be able to search the generated sources, have them available in code completion, and not show as an unresolvable error when used in code. If you do not "active" use the generated sources, you can exclude them. Read how below. Also, when there are generated sources in the target directory, IDEA may end up picking up the entire 'target' directory and not just 'target/'generated-sources'. See #2 below.

2) A configuration in your POM is causing the 'target' directory/directories to be included as source code or as a containing resources.
Certain generated source code configurations can cause this. In one project I worked on, the entire 'target' directory and not just the 'target/'generated-sources' directory got picked up by IDEA as a source directory (the maven plug-in creating the generated code was apparently causing 'target' directory to be seen as a resource.) When running a maven build, IDEA tried to index *everything* in the target directory since it thought it was all resources. If this is happening, a solution is to move the generated-source directory out of the 'target' directory. Configure it so it is a sibling to the 'src' and 'target' directory. Or a child/grandchild of the 'src' directory. If you cannot move this directory, or want to keep in in 'target' so it is deleted when running a 'clean', keep reading for another option. Even if you do not have generated sources, I have seen some plug-ins (or configuration errors or unusual configuration requirements) cause the target directory to get included by IntelliJ IDEA. Some code filtering configurations can cause this. Scan the project tool window in IDEA. If you see any target directories, they are getting included and thus indexed. Excluded directories do not show in the project window. If there are target directories (or you have a 'target/'generated-sources' directory that is causing all of the 'target' directory to be included) you can exclude them in the Project Structure dialog (File > Project Structure). Select the module, and click the 'sources' tab. Navigate to the 'target' directory and exclude it. If there is a generated sources directory, exclude all the other child directories in the 'target directory rather than the 'target' directory. (Do this after running a build so all the possible directories are there).

3) Your build is causing files to get generated inside the included (and therefore indexed) file structure that is subsequently getting indexed. For example, a unit test that creates a large file or a large number of files. You'll need to exclude that directory.

Hopefully the above will solve your issue. That being said, a background task should not make IntelliJ IDEA extremely unresponsive or slow (unless you are on an underpowered computer). You may want to follow the directions located at and submit a performance problem report.

Finally, if none of the above work, and you still want to stop the processing while the maven build is running, you can try toggling on power save mode. (File > Power Save Mode). This disables background code analysis and other background processes. I'm not sure about indexing. If this ends up working for you, you can map a hotkey to it in the keymap (File > Settings > IDE Settings > Keymap) for quicker toggling.

Comment actions Permalink

Thank you for the extensive reply. Very helpful and complete, I checked and the target directories are not included but switching to power saving mode during the external build helped.


Please sign in to leave a comment.