Why does project import with the tooling API make so many HTTP connections?

I’m investigating why my project import in IntelliJ IDEA is slow. When I activate offline mode, performance is acceptable. In online mode, I can see in the profiler that below ProjectImportAction a lot of time is spent in HTTP calls originating from ExternalResourceResolver.resolveStaticDependency.

When I build on the command line, gradle does not need to make HTTP requests if the dependencies are already cached. Why is this different with the tooling API?

You might be hitting a problem we fixed in Gradle 3.2, can you please update and try again?

I’m using 3.2.1, I verified that I’m profiling the correct daemon by looking at the output of gradle --status

There should be no difference between command line and Tooling API. Is there any chance that you could create a project on GitHub that shows the problem? Also, which version of IntelliJ are you using? A profiler snapshot would also help.

I’m using IJ 2016.3.

I don’t think that this depends on the project, I see this for several projects. All project imports in online mode make HTTP requests. If the project has few dependencies, it’s just not noticeable. I’ll be happy to send you a profiling snapshot, where should I send it to?

Maybe this screenshot already contains a clue:

For the rest, there is a huge amount of file operations going on, I’m not sure why that is necessary and it also takes a very long time. The configuration phase on the command line just takes a couple of seconds.