spring-gradle-plugins / dependency-management-plugin

A Gradle plugin that provides Maven-like dependency management functionality
686 stars 85 forks source link

Synchronizations issues in IntelliJ #303

Closed petromir closed 3 years ago

petromir commented 3 years ago

There is an open issue in IntelliJ (https://youtrack.jetbrains.com/issue/IDEA-255314) which is about slow synchronization of Spring Boot project when Gradle is used. According to IntelliJ developers the reason for this issue is in this plugin and more specifically dependency resolution

Their suggestion is

As a workaround, you can try disabling Maven Exclusions processor. Please note, that it may have effect on dependencies resolution result in your project.

which leads to https://docs.spring.io/dependency-management-plugin/docs/current/reference/html/#maven-exclusions-disabling.

I'm trying to understand what should be done from both parties - you and IntelliJ, in order to resolve the issue as it takes ~3 minutes on average Spring Boot project when a synchronization is required (changing dependency or build settings), compared to ~25 seconds building the project from terminal. Also what could be the negative effect on dependencies resolution if Maven exclusions processor is disabled?

wilkinsona commented 3 years ago

Please see my existing comment on the IDEA issue. I don't believe there's anything more that can be done here, unfortunately.

Also what could be the negative effect on dependencies resolution if Maven exclusions processor is disabled?

You may see some dependencies on the classpath that would not appear if the project had been built with Maven. These dependencies can be removed using one of Gradle's standard exclusion mechanisms.

petromir commented 3 years ago

Just to make sure that I understand it right. Let's take this as an example:

compile(group: 'io.opentracing.contrib', name: 'opentracing-spring-jaeger-cloud-starter') {
        exclude group: 'io.opentracing.contrib', module: 'opentracing-spring-cloud-redis-starter'
}

If I disable Maven exclusion with applyMavenExclusions = false and I use another version of opentracing-spring-cloud-redis-starter which is different from the one used in opentracing-spring-jaeger-cloud-starter, then I will still have both versions in the classpath?

wilkinsona commented 3 years ago

What you've shown above is an exclusion configured in your Gradle build and is unaffected by the applyMavenExclusions setting. The setting only affects exclusions configured in the pom files of your project's dependencies. When enabled, those exclusions will be applied with Maven's semantics rather than Gradle's. This is covered in the reference documentation where the different semantics are illustrated with some examples.

petromir commented 3 years ago

Got it. I've enabled the dirty hack for IntelliJ Gradle build logging and I see a lot of failing http requests to get some pom files of some of our internal dependencies in Nexus. Do you think these failures could cause the slowness?

wilkinsona commented 3 years ago

I can't really tell from that description. It's certainly possible, depending on how long each request is taking.

petromir commented 3 years ago

Thanks for clarification. I will post here if I have some findings, so we have some history.

petromir commented 2 years ago

@wilkinsona The issue was caused by missing massive amount of SNAPSHOT artifacts in our Nexus repository. Once we fixed this the time went from 3 minutes to 30 seconds

wilkinsona commented 2 years ago

That's good to hear. Thanks for following up.