Increasing the speed of IntelliJ import

plugins

(Crazyjavahacking) #1

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


(Stefan Oehme) #2

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.


(Chris Doré) #3

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


(Stefan Oehme) #4

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.


(guai) #5

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.

(Stefan Oehme) #6

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.


(guai) #7

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


(Stefan Oehme) #8

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


(guai) #9

@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) {
			}
		}
	}
} 

(Stefan Oehme) #10

@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.


(guai) #11

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:


(Stefan Oehme) #12

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:


(guai) #13

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