Increasing the speed of IntelliJ import

Hi,

is there any way to significantly improve the speed of IntelliJ import of Gradle? We have huge (300+ modules) build that takes quite some time to import into the IntelliJ.

Thanks

The first thing to try is to deactivate the Module for each SourceSet option. This option uses a custom model builder provided by IDEA that is unfortunately very inefficient.

Are there any more details about this inefficiency? A ticket somewhere?

There’s no ticket that I’m aware of, but we’ve talked with the JetBrains engineers and they are planning to overhaul this completely. Feel free to open a ticket on their issue tracker though, it might be useful for others to follow along.

There are two ways of integrating gradle with idea. idea’s own import tool and gradle plugin, which generates idea’s project files (*.ipr, *.iws and *.iml xml files)
You actually can’t control the first one, but can the second one. By default it rebuilds the project too, but you can use -x param to exclude build tasks or exclude them via taskGraph from custom task.
This will decrease project regeneration time considerably but requires more scripting.
Two gotchas:

  1. open an *.ipr and not a folder, or else you’ll get two sets of project files
  2. sometimes you need to open-close-open again freshly generated *.ipr so it be loaded correctly.

You can control it if you uncheck the “Module per SourceSet” option. Then it makes proper use of information provided by the idea DSL.

It doesn’t. If it does anything except generating the IDEA files, then that’s because you (or some plugin you use) added some extra task dependencies to it.

How can it not rebuild the project if it must produce paths to submodules’ jars? It does and its a sound behavior but slow.

It doesn’t do that. Project dependencies are modeled as Idea module dependencies, not as Jar dependencies.

@st_oehme, I don’t know what you talking about. I’m using this plugin for about a year now and it makes deps on jars inside idea project and it rebuilds the project unless I use it like this:

task ideaOnly {
	finalizedBy allprojects*.tasks*.idea
	doFirst {
		allprojects*.tasks.sum().findAll { !it.name.startsWith('idea') }.each {
			try {
				it.enabled = false
			} catch (ignore) {
			}
		}
	}
} 

@guai Again, it doesn’t do that by default, so there must be something wrong in your project. Jars are only used for external dependencies. Projects are referenced as module dependencies.

Please provide a reproducible example and I’m sure we can help you sort this out.

I never said that its a problem. With my task excluding everything but idea tasks this work fast enough.
And best of all it works. Unlike idea’s inner export tool. :slight_smile:

I just wanted to point out that the idea plugin does not build the project and that your workaround should be unnecessary. If you’re happy with it, then that’s fine :slight_smile:

People reading this post can easily hit the same issue. Let them know about it and how to workaround