Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Synchronizing changes in gradle project and IntelliJ IDEA project runs very slowly

I have a gradle project and I use Intellij idea's IDE(version 14). I use my local gradle distribution(version 2.2). When I press the button to refresh all gradle projects, building takes too long but it finishes successfully every time I run it. My repository is on the company's local server. Is it normal?

like image 943
Dandelion Avatar asked Nov 09 '22 15:11

Dandelion


1 Answers

In multi-build gradle where you have many sub modules, I just had this problem and I fixed it by doing this:

First click "Gradle refresh" and watch very closely at each project as it says "Resolving dependencies for (project name) (configuration)". If any of those are taking more than 200ms to complete, then check those projects for a unnecessarily large classpath dependency tree... because it is probably massive when you didn't mean it to be.

This in my case was because every project shared a :shared project and that project had people dumping every dependency you could ever think of as a compile time dependency. So some sub-project that did some minor thing had dependencies from all the other projects basically. It was taking over 1 second to refresh the dependencies for each sub project which really totaled up.

The solution was to switch to transitive = false on that shared project and manually add the dependencies that each project actually needs.

If you have fixed it, you'll no longer see 1-2 second delay when "Resolving dependencies" comes up. They should shoot through very quickly.

like image 186
Nicholas DiPiazza Avatar answered Nov 14 '22 21:11

Nicholas DiPiazza