Gradle build command from terminal finishes in less than a minute but doing a refresh/sync on Intellij IDE taken 15 to 30 minutes. Tried to change the memory (-Xmx) to different levels 1g, 2g,3g upto 8g, still the time taken is in same range. Out project uses around 50 jars from maven/artifactory repo.
I profiled gradle process using YourKit Profiler, but not able to pin point and solve why it is taking so long. Never used YourKit before. Attached screenshots from YourKit below.
Event Timeline shows most of the time is spent on "socket.Read" events (attached below), other events have very negligible time spent.
UPDATE: Using Gradle version 4.1